ServiceDescriptionImporter.AddServiceDescription Method
Adds the specified ServiceDescription to the ServiceDescriptions collection.
[Visual Basic] Public Sub AddServiceDescription( _ ByVal serviceDescription As ServiceDescription, _ ByVal appSettingUrlKey As String, _ ByVal appSettingBaseUrl As String _ ) [C#] public void AddServiceDescription( ServiceDescription serviceDescription, string appSettingUrlKey, string appSettingBaseUrl ); [C++] public: void AddServiceDescription( ServiceDescription* serviceDescription, String* appSettingUrlKey, String* appSettingBaseUrl ); [JScript] public function AddServiceDescription( serviceDescription : ServiceDescription, appSettingUrlKey : String, appSettingBaseUrl : String );
Parameters
- serviceDescription
- The ServiceDescription instance to add to the collection
- appSettingUrlKey
- 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
- 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.
Remarks
The two string parameters, appSettingUrlKey and appSettingBaseUrl, specify how to construct the Url property of the XML Web service proxy that will be generated from the imported ServiceDescription. The appSettingUrlKey parameter specifies that the Url property should be read out of the web.config file's <appsettings> section using the parameter's value as the config key. If the appSettingUrlKey parameter is a null reference (Nothing in Visual Basic) 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 the value of this parameter and the URL specified by the location attribute in the WSDL document. The appSettingUrlKey parameter must also be specified. The Url property will be 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 a null reference (Nothing) or an empty string, the URL is constructed entirely from the value in the web.config file.
Example
[Visual Basic] ' Create a ServiceDescription by reading a .wsdl file. Dim myServiceDescription As ServiceDescription = ServiceDescription.Read("Sample_vb.wsdl") Dim myImporter As New ServiceDescriptionImporter() ' Add the ServiceDescription to the ServiceDescriptionImporter. myImporter.AddServiceDescription(myServiceDescription, "", "") ' Set the protocol name. myImporter.ProtocolName = "Soap" Console.WriteLine("ProtocolName : " + myImporter.ProtocolName) [C#] // Create a ServiceDescription by reading a .wsdl file. ServiceDescription myServiceDescription = ServiceDescription.Read("Sample_CS.wsdl"); ServiceDescriptionImporter myImporter = new ServiceDescriptionImporter(); // Add the ServiceDescription to the ServiceDescriptionImporter. myImporter.AddServiceDescription(myServiceDescription, "", ""); // Set the protocol name. myImporter.ProtocolName = "Soap"; Console.WriteLine("ProtocolName : " + myImporter.ProtocolName); [C++] // Create a ServiceDescription by reading a .wsdl file. ServiceDescription* myServiceDescription = ServiceDescription::Read(S"Sample_cpp.wsdl"); ServiceDescriptionImporter* myImporter = new ServiceDescriptionImporter(); // Add the ServiceDescription to the ServiceDescriptionImporter. myImporter->AddServiceDescription(myServiceDescription, S"", S""); // Set the protocol name. myImporter->ProtocolName = S"Soap"; Console::WriteLine(S"ProtocolName : {0}", myImporter->ProtocolName);
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
ServiceDescriptionImporter Class | ServiceDescriptionImporter Members | System.Web.Services.Description Namespace