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) スキーマ、またはその他の検出ドキュメントを参照できます。 このクラスは、サービスの説明への参照を表します。

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

コンストラクター

名前 説明
ContractReference()

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

ContractReference(String, String)

サービス記述への指定された参照と、サービス記述を実装する XML Web サービスを使用して、 ContractReference クラスの新しいインスタンスを初期化します。

ContractReference(String)

サービスの説明への指定された参照を使用して、 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に書き込みます。

適用対象

こちらもご覧ください