WebReference クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)


WebReference オブジェクトは、Web サービスのセットについての情報を、ServiceDescriptionImporter クラスの静的な GenerateWebReferences メソッドに渡すために使用されます。

using System; using System.CodeDom; using System.CodeDom.Compiler; using System.Security.Permissions; using System.Web.Services; using System.Web.Services.Description; using System.Web.Services.Discovery; using System.Xml; using System.Xml.Serialization; class Test { [SecurityPermissionAttribute(SecurityAction.Demand, Unrestricted=true)] static void Run(){ // Get a WSDL file describing a service. ServiceDescription description = ServiceDescription.Read("DataTypes_CS.wsdl"); // Initialize a service description importer. ServiceDescriptionImporter importer = new ServiceDescriptionImporter(); importer.ProtocolName = "Soap12"; // Use SOAP 1.2. importer.AddServiceDescription(description,null,null); // Report on the service descriptions. Console.WriteLine("Importing {0} service descriptions with {1} associated schemas.", importer.ServiceDescriptions.Count, importer.Schemas.Count); // Generate a proxy client. importer.Style = ServiceDescriptionImportStyle.Client; // Generate properties to represent primitive values. importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties; // Initialize a Code-DOM tree into which we will import the service. CodeNamespace nmspace = new CodeNamespace(); CodeCompileUnit unit1 = new CodeCompileUnit(); unit1.Namespaces.Add(nmspace); // Import the service into the Code-DOM tree. This creates proxy code // that uses the service. ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1); if (warning == 0) { // Generate and print the proxy code in C#. CodeDomProvider provider1 = CodeDomProvider.CreateProvider("CSharp"); provider1.GenerateCodeFromCompileUnit(unit1, Console.Out, new CodeGeneratorOptions()); } else { // Print an error message. Console.WriteLine("Warning: " + warning); } string url = "AddNumbers.wsdl"; // Read in a WSDL service description. 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 and a unit for compilation. CodeNamespace space = new CodeNamespace(); CodeCompileUnit unit = new CodeCompileUnit(); unit.Namespaces.Add(space); // Create a web referernce using the WSDL collection. WebReference reference = new WebReference(wsdlCollection, space); reference.ProtocolName = "Soap12"; // Print some information about the web reference. Console.WriteLine("Base Url = {0}", reference.AppSettingBaseUrl); Console.WriteLine("Url Key = {0}", reference.AppSettingUrlKey); Console.WriteLine("Documents = {0}", reference.Documents.Count); // Create a web reference collection. WebReferenceCollection references = new WebReferenceCollection(); references.Add(reference); // Compile a proxy client and print out the code. CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp"); WebReferenceOptions options = new WebReferenceOptions(); options.Style = ServiceDescriptionImportStyle.Client; options.CodeGenerationOptions = CodeGenerationOptions.GenerateNewAsync; ServiceDescriptionImporter.GenerateWebReferences( references, provider, unit, options ); provider.GenerateCodeFromCompileUnit(unit, Console.Out, new CodeGeneratorOptions() ); } static void Main () { Test.Run(); } }

System.Web.Services.Description.WebReference


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WebReference コンストラクタ (DiscoveryClientDocumentCollection, CodeNamespace, String, String, String)
アセンブリ: System.Web.Services (system.web.services.dll 内)

Public Sub New ( _ documents As DiscoveryClientDocumentCollection, _ proxyCode As CodeNamespace, _ protocolName As String, _ appSettingUrlKey As String, _ appSettingBaseUrl As String _ )
Dim documents As DiscoveryClientDocumentCollection Dim proxyCode As CodeNamespace Dim protocolName As String Dim appSettingUrlKey As String Dim appSettingBaseUrl As String Dim instance As New WebReference(documents, proxyCode, protocolName, appSettingUrlKey, appSettingBaseUrl)
public WebReference ( DiscoveryClientDocumentCollection documents, CodeNamespace proxyCode, string protocolName, string appSettingUrlKey, string appSettingBaseUrl )
public: WebReference ( DiscoveryClientDocumentCollection^ documents, CodeNamespace^ proxyCode, String^ protocolName, String^ appSettingUrlKey, String^ appSettingBaseUrl )
public WebReference ( DiscoveryClientDocumentCollection documents, CodeNamespace proxyCode, String protocolName, String appSettingUrlKey, String appSettingBaseUrl )
public function WebReference ( documents : DiscoveryClientDocumentCollection, proxyCode : CodeNamespace, protocolName : String, appSettingUrlKey : String, appSettingBaseUrl : String )
- protocolName

documents コレクションには、ServiceDescription オブジェクトおよび XmlSchema オブジェクトだけを含めます。これは、GenerateWebReferences メソッドが、DiscoveryDocument オブジェクトを解釈できないからです。

// 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); }
// 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).", System.Convert.ToString(reference.get_Documents().get_Count())); Console.WriteLine("The protocol name is {0}.", reference.get_ProtocolName()); Console.WriteLine("The base URL is {0}.", reference.get_AppSettingBaseUrl()); Console.WriteLine("The URL key is {0}.", reference.get_AppSettingUrlKey()); // Print some information about the proxy code namespace. Console.WriteLine("The proxy code namespace is {0}.", reference.get_ProxyCode().get_Name()); // Print some information about the validation warnings. Console.WriteLine("There are {0} validation warnings.", System.Convert.ToString(reference.get_ValidationWarnings(). get_Count())); // Print some information about the warnings. if (reference.get_Warnings(). Equals((System.Web.Services.Description. ServiceDescriptionImportWarnings)0)) { Console.WriteLine("There are no warnings."); } else { Console.WriteLine("Warnings: " + reference.get_Warnings()); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WebReference コンストラクタ (DiscoveryClientDocumentCollection, CodeNamespace)
アセンブリ: System.Web.Services (system.web.services.dll 内)

Dim documents As DiscoveryClientDocumentCollection Dim proxyCode As CodeNamespace Dim instance As New WebReference(documents, proxyCode)
public function WebReference ( documents : DiscoveryClientDocumentCollection, proxyCode : CodeNamespace )

documents コレクションには、ServiceDescription オブジェクトおよび XmlSchema オブジェクトだけを含めます。これは、GenerateWebReferences メソッドが、DiscoveryDocument オブジェクトを解釈できないからです。


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WebReference コンストラクタ (DiscoveryClientDocumentCollection, CodeNamespace, String, String)
アセンブリ: System.Web.Services (system.web.services.dll 内)

Public Sub New ( _ documents As DiscoveryClientDocumentCollection, _ proxyCode As CodeNamespace, _ appSettingUrlKey As String, _ appSettingBaseUrl As String _ )
Dim documents As DiscoveryClientDocumentCollection Dim proxyCode As CodeNamespace Dim appSettingUrlKey As String Dim appSettingBaseUrl As String Dim instance As New WebReference(documents, proxyCode, appSettingUrlKey, appSettingBaseUrl)
public WebReference ( DiscoveryClientDocumentCollection documents, CodeNamespace proxyCode, string appSettingUrlKey, string appSettingBaseUrl )
public: WebReference ( DiscoveryClientDocumentCollection^ documents, CodeNamespace^ proxyCode, String^ appSettingUrlKey, String^ appSettingBaseUrl )
public WebReference ( DiscoveryClientDocumentCollection documents, CodeNamespace proxyCode, String appSettingUrlKey, String appSettingBaseUrl )
public function WebReference ( documents : DiscoveryClientDocumentCollection, proxyCode : CodeNamespace, appSettingUrlKey : String, appSettingBaseUrl : String )

documents コレクションには、ServiceDescription オブジェクトおよび XmlSchema オブジェクトだけを含めます。これは、GenerateWebReferences メソッドが、DiscoveryDocument オブジェクトを解釈できないからです。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WebReference コンストラクタ

名前 | 説明 |
---|---|
WebReference (DiscoveryClientDocumentCollection, CodeNamespace) | 説明のドキュメントのコレクションおよびプロキシ コード名前空間を指定して、WebReference クラスの新しいインスタンスを初期化します。 |
WebReference (DiscoveryClientDocumentCollection, CodeNamespace, String, String) | 指定したデータを使用して、WebReference クラスの新しいインスタンスを初期化します。 |
WebReference (DiscoveryClientDocumentCollection, CodeNamespace, String, String, String) | 指定したデータを使用して、WebReference クラスの新しいインスタンスを初期化します。 |

WebReference プロパティ

名前 | 説明 | |
---|---|---|
![]() | AppSettingBaseUrl | Web 参照のベース URL を取得します。 |
![]() | AppSettingUrlKey | Web 参照の URL キーを取得します。 |
![]() | Documents | Web 参照に関連付けられている説明のドキュメントのコレクションを取得します。 |
![]() | ProtocolName | Web 参照に関連付けられているプロトコルを取得または設定します。 |
![]() | ProxyCode | Web 参照に関連付けられているコード名前空間を取得します。 |
![]() | ValidationWarnings | 説明のドキュメントを検証するときに生成される警告のコレクションを取得します。 |
![]() | Warnings | Web サービス記述言語 (WSDL: Web Services Description Language) サービスの説明のドキュメントをインポートするときに生成される警告のコレクションを取得します。 |

WebReference メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

WebReference メンバ
XML Web サービスのコレクションへの参照を記述します。
WebReference データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | AppSettingBaseUrl | Web 参照のベース URL を取得します。 |
![]() | AppSettingUrlKey | Web 参照の URL キーを取得します。 |
![]() | Documents | Web 参照に関連付けられている説明のドキュメントのコレクションを取得します。 |
![]() | ProtocolName | Web 参照に関連付けられているプロトコルを取得または設定します。 |
![]() | ProxyCode | Web 参照に関連付けられているコード名前空間を取得します。 |
![]() | ValidationWarnings | 説明のドキュメントを検証するときに生成される警告のコレクションを取得します。 |
![]() | Warnings | Web サービス記述言語 (WSDL: Web Services Description Language) サービスの説明のドキュメントをインポートするときに生成される警告のコレクションを取得します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からWebReferenceを検索する場合は、下記のリンクをクリックしてください。

- WebReferenceのページへのリンク