語言

WebReference 建構函式

定義

初始化 WebReference 類別的新執行個體。

多載

名稱 Description
WebReference(DiscoveryClientDocumentCollection, CodeNamespace)

初始化一個新實例 WebReference ,使用給定的描述、文件集合及代理代碼空間。

WebReference(DiscoveryClientDocumentCollection, CodeNamespace, String, String)

初始化一個新的類別實例 WebReference ,並使用給定資料。

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

初始化一個新的類別實例 WebReference ,並使用給定資料。

WebReference(DiscoveryClientDocumentCollection, CodeNamespace)

初始化一個新實例 WebReference ,使用給定的描述、文件集合及代理代碼空間。

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)

參數

proxyCode
CodeNamespace

CodeNamespace A 指定一個用於編譯的命名空間。

範例

以下程式碼範例說明了此建構子的使用方式。 此程式碼範例是本類別更大範例 WebReference 的一部分。

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

備註

集合 documents 應僅 ServiceDescription 包含 和 XmlSchema 物件;方法 GenerateWebReferences 無法解釋 DiscoveryDocument 物件。

適用於

WebReference(DiscoveryClientDocumentCollection, CodeNamespace, String, String)

初始化一個新的類別實例 WebReference ,並使用給定資料。

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)

參數

proxyCode
CodeNamespace

CodeNamespace A 指定一個用於編譯的命名空間。

appSettingUrlKey
String

網頁參考的網址金鑰。

appSettingBaseUrl
String

網頁參考的基礎網址。

備註

集合 documents 應僅 ServiceDescription 包含 和 XmlSchema 物件;方法 GenerateWebReferences 無法解釋 DiscoveryDocument 物件。

適用於

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

初始化一個新的類別實例 WebReference ,並使用給定資料。

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)

參數

proxyCode
CodeNamespace

CodeNamespace A 指定一個用於編譯的命名空間。

protocolName
String

XML 網路服務所使用的協定。

appSettingUrlKey
String

網頁參考的網址金鑰。

appSettingBaseUrl
String

網頁參考的基礎網址。

範例

以下程式碼範例說明如何使用此建構子。

// 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 應僅 ServiceDescription 包含 和 XmlSchema 物件;方法 GenerateWebReferences 無法解釋 DiscoveryDocument 物件。

適用於