ServiceDescriptionImporter.AddServiceDescription 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将指定的 ServiceDescription 添加到要导入的 ServiceDescriptions 值的集合中。
public:
void AddServiceDescription(System::Web::Services::Description::ServiceDescription ^ serviceDescription, System::String ^ appSettingUrlKey, System::String ^ appSettingBaseUrl);
public void AddServiceDescription(System.Web.Services.Description.ServiceDescription serviceDescription, string appSettingUrlKey, string appSettingBaseUrl);
member this.AddServiceDescription : System.Web.Services.Description.ServiceDescription * string * string -> unit
Public Sub AddServiceDescription (serviceDescription As ServiceDescription, appSettingUrlKey As String, appSettingBaseUrl As String)
参数
- serviceDescription
- ServiceDescription
要添加到集合的 ServiceDescription 实例。
- appSettingUrlKey
- String
将代理类的 Url 属性的初始值设置为从 serviceDescription 参数所表示的实例生成。 指定它应该从 web.config 文件的 <appsetting> 节生成。
- appSettingBaseUrl
- String
将代理类的 Url 属性的初始值设置为从 serviceDescription 参数所表示的实例生成。 指定它应该通过该参数的值和由 WSDL 文档中的 location 特性指定的 URL 的组合来构造。
示例
以下示例演示了在使用 AddServiceDescription 类时如何使用 ServiceDescriptionImporter 方法。
// Initialize a service description importer.
ServiceDescriptionImporter^ importer = gcnew ServiceDescriptionImporter;
importer->ProtocolName = "Soap12"; // Use SOAP 1.2.
importer->AddServiceDescription( description, nullptr, nullptr );
// Initialize a service description importer.
ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
importer.ProtocolName = "Soap12"; // Use SOAP 1.2.
importer.AddServiceDescription(description,null,null);
注解
使用此方法可将实例添加到 ServiceDescription 集合中,该集合将在调用 方法时 Import 导入。
两个字符串参数 appSettingUrlKey 和 appSettingBaseUrl指定如何构造 Url 要从导入 ServiceDescription 的值生成的 XML Web 服务代理的 属性。
appSettingUrlKey参数指定Url应通过使用参数值作为配置键,从 web.config 文件的 <appsettings> 节中读出 属性。
appSettingUrlKey如果参数为null或空字符串,则初始值由 location Web 服务描述语言 (WSDL) 文档中的属性确定。 如果 的StyleServer值为 ,则如果尝试设置 参数的值,appSettingUrlKey则会引发错误。
参数 appSettingBaseUrl 指定属性的初始值 Url 应从此参数值与 WSDL 文档中的 location 属性指定的 URL 的组合构造。
appSettingUrlKey还必须指定 参数。 通过将 Url 从 appSettingBaseUrl 参数和 WSDL 指定的 URL) 构造的相对 URL (与从 web.config 文件加载的 URL 相结合来构造 属性。 如果此参数为 null 或空字符串,则完全从 web.config 文件中的值构造 URL。