ContractReference クラス

定義

探索ドキュメント内にあるサービスの説明への参照を表します。

public ref class ContractReference : System::Web::Services::Discovery::DiscoveryReference
public class ContractReference : System.Web.Services.Discovery.DiscoveryReference
type ContractReference = class
    inherit DiscoveryReference
Public Class ContractReference
Inherits DiscoveryReference
継承
ContractReference

#using <System.Xml.dll>
#using <System.Web.Services.dll>

using namespace System;
using namespace System::Xml;
using namespace System::IO;
using namespace System::Web::Services::Discovery;
int main()
{
   try
   {
      
      // Get a DiscoveryDocument.
      DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument;
      
      // Get a ContractReference.
      ContractReference^ myContractReference = gcnew ContractReference;
      
      // Set the URL to the referenced service description.
      myContractReference->Ref = "http://localhost/service1.asmx?wsdl";
      
      // Set the URL for an XML Web service implementing the service
      // description.
      myContractReference->DocRef = "http://localhost/service1.asmx";
      SoapBinding^ myBinding = gcnew SoapBinding;
      myBinding->Binding = gcnew XmlQualifiedName( "q1:Service1Soap" );
      myBinding->Address = "http://localhost/service1.asmx";
      
      // Add myContractReference to the list of references contained
      // in the discovery document.
      myDiscoveryDocument->References->Add( myContractReference );
      
      // Add Binding to the references collection.
      myDiscoveryDocument->References->Add( myBinding );
      
      // Open or create a file for writing.
      FileStream^ myFileStream = gcnew FileStream( "Service1.disco",FileMode::OpenOrCreate,FileAccess::Write );
      StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream );
      
      // Write myDiscoveryDocument into the passed stream.
      myDiscoveryDocument->Write( myStreamWriter );
      Console::WriteLine( "The Service1.disco is generated." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Error is {0}", e->Message );
   }

}
using System;
using System.Xml;
using System.IO;
using System.Web.Services.Discovery;

public class MyContractReference
{
   static void Main()
   {
      try
      {
         // Get a DiscoveryDocument.
         DiscoveryDocument myDiscoveryDocument = new  DiscoveryDocument();

         // Get a ContractReference.
         ContractReference myContractReference = new ContractReference();

         // Set the URL to the referenced service description.
         myContractReference.Ref = "http://localhost/service1.asmx?wsdl";

         // Set the URL for an XML Web service implementing the service
         // description.
         myContractReference.DocRef = "http://localhost/service1.asmx";
         SoapBinding myBinding = new SoapBinding();
         myBinding.Binding = new XmlQualifiedName("q1:Service1Soap");
         myBinding.Address = "http://localhost/service1.asmx";

         // Add myContractReference to the list of references contained
         // in the discovery document.
         myDiscoveryDocument.References.Add(myContractReference);

         // Add Binding to the references collection.
         myDiscoveryDocument.References.Add(myBinding);

         // Open or create a file for writing.
         FileStream myFileStream = new FileStream("Service1.disco",
             FileMode.OpenOrCreate, FileAccess.Write );
         StreamWriter myStreamWriter = new StreamWriter( myFileStream );

         // Write myDiscoveryDocument into the passed stream.
         myDiscoveryDocument.Write( myStreamWriter );
         Console.WriteLine("The Service1.disco is generated.");
      }
      catch(Exception e)
      {
         Console.WriteLine("Error is "+ e.Message);
      }
   }
}
Imports System.Xml
Imports System.IO
Imports System.Web.Services.Discovery

Public Class MyContractReference
   Shared Sub Main()
      Try
         ' Get a 'DiscoveryDocument' object.
         Dim myDiscoveryDocument As New DiscoveryDocument()
         ' Get a 'ContractReference' object.
         Dim myContractReference As New ContractReference()
         ' Set the URL to the referenced service description.
         myContractReference.Ref = "http://localhost/service1.asmx?wsdl"
         ' Set the URL for a XML Web service implementing the service
         ' description .
         myContractReference.DocRef = "http://localhost/service1.asmx"
         Dim myBinding As New SoapBinding()
         myBinding.Binding = New XmlQualifiedName("q1:Service1Soap")
         myBinding.Address = "http://localhost/service1.asmx"
         ' Add 'myContractReference' to the list of references contained 
         ' within the discovery document.
         myDiscoveryDocument.References.Add(myContractReference)
         ' Add 'Binding' to referenceCollection.
         myDiscoveryDocument.References.Add(myBinding)
         ' Open or create a file for writing .
         Dim myFileStream As New FileStream("Service1.disco", FileMode.OpenOrCreate, FileAccess.Write)
         Dim myStreamWriter As New StreamWriter(myFileStream)
         ' Write 'myDiscoveryDocument' into the passed stream.
         myDiscoveryDocument.Write(myStreamWriter)
         Console.WriteLine("The 'Service1.disco' is generated.")
      Catch e As Exception
         Console.WriteLine("Error is" + e.Message)
      End Try
   End Sub
End Class

注釈

XML Web サービスの検出には、URL を指定して使用可能な Web サービスを検出する必要があります。 URL は通常、検出ドキュメントを指します。これは通常、ファイル名拡張子が a.disco です。 検出ドキュメント内には、XML Web サービスの存在に関する情報への参照が含まれます。 これらの参照は、サービスの説明、XML スキーマ定義言語 (XSD) スキーマ、またはその他の検出ドキュメントを参照できます。 このクラスは、サービスの説明への参照を表します。

探索ドキュメント内では、サービスの説明への参照が XML 要素内に contractRef 含まれます。 contractRef XML 要素には、 と docRefの 2 つの属性がありますref。 要素にはcontractRef定数に一致する Namespace XML 名前空間が必要ですが、 ref 属性と docRef 属性は および DocRef プロパティにRef配置されます。

コンストラクター

ContractReference()

既定値を使用して ContractReference クラスの新しいインスタンスを初期化します。

ContractReference(String)

サービスの説明への参照を指定して、ContractReference の新しいインスタンスを初期化します。

ContractReference(String, String)

サービスの説明への参照、およびサービスの説明を実装している XML Web サービスを指定して、ContractReference クラスの新しいインスタンスを初期化します。

フィールド

Namespace

探索ドキュメント内にあるサービスの説明を参照するための XML 名前空間。

プロパティ

ClientProtocol

探索処理で使用する DiscoveryClientProtocol のインスタンスを取得または設定します。

(継承元 DiscoveryReference)
Contract

サービスの説明を表す ServiceDescription オブジェクトを取得します。

DefaultFilename

参照先のサービスの説明を保存するときに使用する既定のファイル名を取得します。

DocRef

Ref プロパティで参照されるサービスの説明を実装している XML Web サービスの URL を取得または設定します。

Ref

参照されるサービスの説明の場所を示す URL を取得または設定します。

Url

参照されるサービスの説明の場所を示す URL を取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ReadDocument(Stream)

渡された Stream からサービスの説明を読み取り、サービスの説明を返します。

Resolve()

Url にある参照されるドキュメントをダウンロードして、参照されるドキュメントが有効かどうかを解決します。

(継承元 DiscoveryReference)
Resolve(String, Stream)

参照先のドキュメントが有効かどうかを解決します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
WriteDocument(Object, Stream)

渡された Stream に渡されたサービスの説明を書き込みます。

適用対象

こちらもご覧ください