WebReference 构造函数

定义

初始化 WebReference 类的新实例。Initializes a new instance of the WebReference class.

重载

WebReference()
WebReference(DiscoveryClientDocumentCollection, CodeNamespace)

使用给定的说明文档集合和代理代码命名空间初始化 WebReference 类的新实例。Initializes a new instance of the WebReference class with the given description document collection and proxy code namespace.

WebReference(DiscoveryClientDocumentCollection, CodeNamespace, String, String)

使用给定数据初始化 WebReference 类的新实例。Initializes a new instance of the WebReference class with the given data.

WebReference(DiscoveryClientDocumentCollection, CodeNamespace, String, String, String)

使用给定数据初始化 WebReference 类的新实例。Initializes a new instance of the WebReference class with the given data.

WebReference()

public:
 WebReference();
public WebReference ();
Public Sub New ()

适用于

WebReference(DiscoveryClientDocumentCollection, CodeNamespace)

使用给定的说明文档集合和代理代码命名空间初始化 WebReference 类的新实例。Initializes a new instance of the WebReference class with the given description document collection and proxy code namespace.

public:
 WebReference(System::Web::Services::Discovery::DiscoveryClientDocumentCollection ^ documents, System::CodeDom::CodeNamespace ^ proxyCode);
public WebReference (System.Web.Services.Discovery.DiscoveryClientDocumentCollection documents, System.CodeDom.CodeNamespace proxyCode);
new System.Web.Services.Description.WebReference : System.Web.Services.Discovery.DiscoveryClientDocumentCollection * System.CodeDom.CodeNamespace -> System.Web.Services.Description.WebReference
Public Sub New (documents As DiscoveryClientDocumentCollection, proxyCode As CodeNamespace)

参数

documents
DiscoveryClientDocumentCollection

用于指定一个说明文档集合的 DiscoveryClientDocumentCollectionA DiscoveryClientDocumentCollection that specifies a collection of description documents.

proxyCode
CodeNamespace

指定代码编译的命名空间的 CodeNamespaceA CodeNamespace that specifies a namespace for code compilation.

示例

下面的代码示例演示如何使用此构造函数。The following code example illustrates the use of this constructor. 此代码示例是为类提供的更大示例的一部分 WebReferenceThis code example is part of a larger example provided for the WebReference class.

// Create a web referernce using the WSDL collection.
WebReference reference = new WebReference(wsdlCollection, space);
reference.ProtocolName = "Soap12";

注解

documents集合应仅包含 ServiceDescriptionXmlSchema 对象; GenerateWebReferences 方法无法解释 DiscoveryDocument 对象。The documents collection should contain only ServiceDescription and XmlSchema objects; the GenerateWebReferences method is unable to interpret DiscoveryDocument objects.

适用于

WebReference(DiscoveryClientDocumentCollection, CodeNamespace, String, String)

使用给定数据初始化 WebReference 类的新实例。Initializes a new instance of the WebReference class with the given data.

public:
 WebReference(System::Web::Services::Discovery::DiscoveryClientDocumentCollection ^ documents, System::CodeDom::CodeNamespace ^ proxyCode, System::String ^ appSettingUrlKey, System::String ^ appSettingBaseUrl);
public WebReference (System.Web.Services.Discovery.DiscoveryClientDocumentCollection documents, System.CodeDom.CodeNamespace proxyCode, string appSettingUrlKey, string appSettingBaseUrl);
new System.Web.Services.Description.WebReference : System.Web.Services.Discovery.DiscoveryClientDocumentCollection * System.CodeDom.CodeNamespace * string * string -> System.Web.Services.Description.WebReference
Public Sub New (documents As DiscoveryClientDocumentCollection, proxyCode As CodeNamespace, appSettingUrlKey As String, appSettingBaseUrl As String)

参数

documents
DiscoveryClientDocumentCollection

用于指定一个说明文档集合的 DiscoveryClientDocumentCollectionA DiscoveryClientDocumentCollection that specifies a collection of description documents.

proxyCode
CodeNamespace

指定代码编译的命名空间的 CodeNamespaceA CodeNamespace that specifies a namespace for code compilation.

appSettingUrlKey
String

Web 引用的 URL 键。The URL key of the Web reference.

appSettingBaseUrl
String

Web 引用的基础 URL。The base URL of the Web reference.

注解

documents集合应仅包含 ServiceDescriptionXmlSchema 对象; GenerateWebReferences 方法无法解释 DiscoveryDocument 对象。The documents collection should contain only ServiceDescription and XmlSchema objects; the GenerateWebReferences method is unable to interpret DiscoveryDocument objects.

适用于

WebReference(DiscoveryClientDocumentCollection, CodeNamespace, String, String, String)

使用给定数据初始化 WebReference 类的新实例。Initializes a new instance of the WebReference class with the given data.

public:
 WebReference(System::Web::Services::Discovery::DiscoveryClientDocumentCollection ^ documents, System::CodeDom::CodeNamespace ^ proxyCode, System::String ^ protocolName, System::String ^ appSettingUrlKey, System::String ^ appSettingBaseUrl);
public WebReference (System.Web.Services.Discovery.DiscoveryClientDocumentCollection documents, System.CodeDom.CodeNamespace proxyCode, string protocolName, string appSettingUrlKey, string appSettingBaseUrl);
new System.Web.Services.Description.WebReference : System.Web.Services.Discovery.DiscoveryClientDocumentCollection * System.CodeDom.CodeNamespace * string * string * string -> System.Web.Services.Description.WebReference
Public Sub New (documents As DiscoveryClientDocumentCollection, proxyCode As CodeNamespace, protocolName As String, appSettingUrlKey As String, appSettingBaseUrl As String)

参数

documents
DiscoveryClientDocumentCollection

用于指定一个说明文档集合的 DiscoveryClientDocumentCollectionA DiscoveryClientDocumentCollection that specifies a collection of description documents.

proxyCode
CodeNamespace

指定代码编译的命名空间的 CodeNamespaceA CodeNamespace that specifies a namespace for code compilation.

protocolName
String

XML Web services 使用的协议。The protocol used by the XML Web service.

appSettingUrlKey
String

Web 引用的 URL 键。The URL key of the Web reference.

appSettingBaseUrl
String

Web 引用的基础 URL。The base URL of the Web reference.

示例

下面的代码示例演示如何使用此构造函数。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);
}

注解

documents集合应仅包含 ServiceDescriptionXmlSchema 对象; GenerateWebReferences 方法无法解释 DiscoveryDocument 对象。The documents collection should contain only ServiceDescription and XmlSchema objects; the GenerateWebReferences method is unable to interpret DiscoveryDocument objects.

适用于