Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ServiceDescriptionImporter.AddServiceDescription Method

Adds the specified ServiceDescription to the collection of ServiceDescriptions values to be imported.

Namespace:  System.Web.Services.Description
Assembly:  System.Web.Services (in System.Web.Services.dll)

public void AddServiceDescription(
	ServiceDescription serviceDescription,
	string appSettingUrlKey,
	string appSettingBaseUrl
)

Parameters

serviceDescription
Type: System.Web.Services.Description.ServiceDescription

The ServiceDescription instance to add to the collection

appSettingUrlKey
Type: System.String

Sets the initial value of the Url property of the proxy class to be generated from the instance represented by the serviceDescription parameter. Specifies that it should be generated from the web.config file's <appsetting> section.

appSettingBaseUrl
Type: System.String

Sets the initial value of the Url property of the proxy class to be generated from the instance represented by the serviceDescription parameter. Specifies that it should be constructed from a combination of the value of this parameter and the URL specified by the location attribute in the WSDL document.

Use this method to add ServiceDescription instances to the collection that is to be imported when the Import method is called.

The two string parameters, appSettingUrlKey and appSettingBaseUrl, specify how to construct the Url property of the XML Web service proxy that is to be generated from the imported ServiceDescription value. The appSettingUrlKey parameter specifies that the Url property should be read out of the web.config file's <appsettings> section by using the parameter value as the configuration key. If the appSettingUrlKey parameter is null or an empty string, the initial value is determined by the location attribute in the Web Services Description Language (WSDL) document. If the value of Style is Server, an error is raised if you attempt to set the value of the appSettingUrlKey parameter.

The appSettingBaseUrl parameter specifies that the initial value for the Url property should be constructed from a combination of this parameter value and the URL specified by the location attribute in the WSDL document. The appSettingUrlKey parameter must also be specified. The Url property is constructed by combining a relative URL (constructed from the appSettingBaseUrl parameter and the WSDL-specified URL) with the URL loaded from the web.config file. If this parameter is null or an empty string, the URL is constructed entirely from the value in the web.config file.

The following example illustrates the use of the AddServiceDescription method when using the ServiceDescriptionImporter class.

// Initialize a service description importer.
ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
importer.ProtocolName = "Soap12";  // Use SOAP 1.2.
importer.AddServiceDescription(description,null,null);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 3.5 SP1
Show:
© 2015 Microsoft