WebReference Constructor (DiscoveryClientDocumentCollection^, CodeNamespace^, String^, String^, String^)

 

Initializes a new instance of the WebReference class with the given data.

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

public:
WebReference(
	DiscoveryClientDocumentCollection^ documents,
	CodeNamespace^ proxyCode,
	String^ protocolName,
	String^ appSettingUrlKey,
	String^ appSettingBaseUrl
)

Parameters

documents
Type: System.Web.Services.Discovery::DiscoveryClientDocumentCollection^

A DiscoveryClientDocumentCollection that specifies a collection of description documents.

proxyCode
Type: System.CodeDom::CodeNamespace^

A CodeNamespace that specifies a namespace for code compilation.

protocolName
Type: System::String^

The protocol used by the XML Web service.

appSettingUrlKey
Type: System::String^

The URL key of the Web reference.

appSettingBaseUrl
Type: System::String^

The base URL of the Web reference.

The documents collection should contain only ServiceDescription and XmlSchema objects; the GenerateWebReferences method is unable to interpret DiscoveryDocument objects.

The following code example shows how to use this constructor.

// Read in a WSDL service description.
string url = "http://www.contoso.com/Example/WebService.asmx?WSDL";
XmlTextReader reader = new XmlTextReader(url);
ServiceDescription wsdl = ServiceDescription.Read(reader);

// Create a WSDL collection.
DiscoveryClientDocumentCollection wsdlCollection = 
    new DiscoveryClientDocumentCollection();
wsdlCollection.Add(url, wsdl);

// Create a namespace.
CodeNamespace proxyNamespace = new CodeNamespace("ExampleNamespace");

// Create a web reference using the WSDL collection.
string baseUrl = "http://www.contoso.com";
string urlKey = "ExampleUrlKey";
string protocolName = "Soap12";
WebReference reference = new WebReference(
    wsdlCollection, proxyNamespace, protocolName, urlKey, baseUrl);

// Print some information about the web reference.
Console.WriteLine("The WebReference object contains {0} document(s).", 
    reference.Documents.Count);
Console.WriteLine("The protocol name is {0}.", reference.ProtocolName);
Console.WriteLine("The base URL is {0}.", reference.AppSettingBaseUrl);
Console.WriteLine("The URL key is {0}.", reference.AppSettingUrlKey);

// Print some information about the proxy code namespace.
Console.WriteLine("The proxy code namespace is {0}.", 
    reference.ProxyCode.Name);

// Print some information about the validation warnings.
Console.WriteLine("There are {0} validation warnings.",
    reference.ValidationWarnings.Count);

// Print some information about the warnings.
if (reference.Warnings == 0)
{
    Console.WriteLine("There are no warnings.");
}
else
{
    Console.WriteLine("Warnings: " + reference.Warnings);
}

.NET Framework
Available since 2.0
Return to top
Show: