WebReferenceとは? わかりやすく解説

WebReference クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

XML Web サービスコレクションへの参照記述します

名前空間: System.Web.Services.Description
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

Public NotInheritable Class
 WebReference
public sealed class WebReference
public ref class WebReference sealed
public final class WebReference
public final class WebReference
解説解説

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.Object
  System.Web.Services.Description.WebReference
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebReference メンバ
System.Web.Services.Description 名前空間

WebReference コンストラクタ (DiscoveryClientDocumentCollection, CodeNamespace, String, String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定したデータ使用して、WebReference クラス新しインスタンス初期化します。

名前空間: System.Web.Services.Description
アセンブリ: 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
)

パラメータ

documents

説明ドキュメントコレクション指定するDiscoveryClientDocumentCollection。

proxyCode

コード コンパイル名前空間指定する CodeNamespace。

protocolName

XML Web サービスによって使用されるプロトコル

appSettingUrlKey

Web 参照URL キー

appSettingBaseUrl

Web 参照ベース URL

解説解説

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());
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebReference クラス
WebReference メンバ
System.Web.Services.Description 名前空間

WebReference コンストラクタ (DiscoveryClientDocumentCollection, CodeNamespace)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

説明ドキュメントコレクションおよびプロキシ コード名前空間を指定して、WebReference クラス新しインスタンス初期化します。

名前空間: System.Web.Services.Description
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

Public Sub New ( _
    documents As DiscoveryClientDocumentCollection, _
    proxyCode As CodeNamespace _
)
Dim documents As DiscoveryClientDocumentCollection
Dim proxyCode As CodeNamespace

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

パラメータ

documents

説明ドキュメントコレクション指定するDiscoveryClientDocumentCollection。

proxyCode

コード コンパイル名前空間指定する CodeNamespace。

解説解説

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

使用例使用例

このコンストラクタ使用方法を示すコードの例次に示します。このコード例は、WebReference クラストピック取り上げているコード例一部分です。

// Create a web referernce using the WSDL collection.
WebReference reference = new WebReference(wsdlCollection, space);
reference.ProtocolName = "Soap12";
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebReference クラス
WebReference メンバ
System.Web.Services.Description 名前空間

WebReference コンストラクタ (DiscoveryClientDocumentCollection, CodeNamespace, String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定したデータ使用して、WebReference クラス新しインスタンス初期化します。

名前空間: System.Web.Services.Description
アセンブリ: 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

説明ドキュメントコレクション指定するDiscoveryClientDocumentCollection。

proxyCode

コード コンパイル名前空間指定する CodeNamespace。

appSettingUrlKey

Web 参照URL キー

appSettingBaseUrl

Web 参照ベース URL

解説解説

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

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebReference クラス
WebReference メンバ
System.Web.Services.Description 名前空間

WebReference コンストラクタ

WebReference クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

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

関連項目

WebReference クラス
WebReference メンバ
System.Web.Services.Description 名前空間

WebReference プロパティ


WebReference メソッド


WebReference メンバ

XML Web サービスコレクションへの参照記述します

WebReference データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

WebReference クラス
System.Web.Services.Description 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からWebReferenceを検索した結果を表示しています。
Weblioに収録されているすべての辞書からWebReferenceを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からWebReference を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「WebReference」の関連用語

WebReferenceのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WebReferenceのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS