ContractReference.Contract-Eigenschaft

Ruft ein System.Web.Services.Description.ServiceDescription-Objekt ab, das die Dienstbeschreibung darstellt.

Namespace: System.Web.Services.Discovery
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public ReadOnly Property Contract As ServiceDescription
'Usage
Dim instance As ContractReference
Dim value As ServiceDescription

value = instance.Contract
public ServiceDescription Contract { get; }
public:
property ServiceDescription^ Contract {
    ServiceDescription^ get ();
}
/** @property */
public ServiceDescription get_Contract ()
public function get Contract () : ServiceDescription

Eigenschaftenwert

Ein System.Web.Services.Description.ServiceDescription-Objekt, das die Dienstbeschreibung darstellt.

Ausnahmen

Ausnahmetyp Bedingung

InvalidOperationException

Die ClientProtocol-Eigenschaft ist NULL (Nothing in Visual Basic).

Exception

Die Documents-Eigenschaft von ClientProtocol enthält kein Discovery-Dokument mit einem URL von Url.

Beispiel

Class MyClass1
   Shared Sub Main()
      Try
         ' Create the file stream.
         Dim discoStream As _
             New FileStream("Service1_vb.disco", FileMode.Open)

         ' Create the discovery document.
         Dim myDiscoveryDocument As _
             DiscoveryDocument = DiscoveryDocument.Read(discoStream)

         ' Get the first ContractReference in the collection.
         Dim myContractReference As ContractReference = _
             CType(myDiscoveryDocument.References(0), ContractReference)

         ' Set the client protocol.
         myContractReference.ClientProtocol = New DiscoveryClientProtocol()
         myContractReference.ClientProtocol.Credentials = _
             CredentialCache.DefaultCredentials

         ' Get the service description.
         Dim myContract As ServiceDescription = myContractReference.Contract

         ' Create the service description file.
         myContract.Write("MyService1.wsdl")
         Console.WriteLine("The WSDL file created is MyService1.wsdl")

         discoStream.Close()

      Catch ex As Exception
         Console.WriteLine("Exception: " + ex.Message)
      End Try
   End Sub 'Main
End Class 'MyClass1
class MyClass1
{
   static void Main()
   {
      try
      {
         // Create the file stream.
         FileStream discoStream = 
             new FileStream("Service1_CS.disco",FileMode.Open);

         // Create the discovery document.
         DiscoveryDocument myDiscoveryDocument = 
             DiscoveryDocument.Read(discoStream);

         // Get the first ContractReference in the collection.
         ContractReference myContractReference =
             (ContractReference)myDiscoveryDocument.References[0];

         // Set the client protocol.
         myContractReference.ClientProtocol = new DiscoveryClientProtocol();
         myContractReference.ClientProtocol.Credentials = 
             CredentialCache.DefaultCredentials;

         // Get the service description.
         ServiceDescription myContract = myContractReference.Contract;

         // Create the service description file.
         myContract.Write("MyService1.wsdl");
         Console.WriteLine("The WSDL file created is MyService1.wsdl");

         discoStream.Close();
      }
      catch(Exception ex)
      {
         Console.WriteLine("Exception: " + ex.Message);
      }
   }
}
int main()
{
   try
   {
      // Create the file stream.
      FileStream^ discoStream = gcnew FileStream( "Service1_CS.disco",FileMode::Open );
      
      // Create the discovery document.
      DiscoveryDocument^ myDiscoveryDocument = DiscoveryDocument::Read( discoStream );
      
      // Get the first ContractReference in the collection.
      ContractReference^ myContractReference = dynamic_cast<ContractReference^>(myDiscoveryDocument->References[ 0 ]);
      
      // Set the client protocol.
      myContractReference->ClientProtocol = gcnew DiscoveryClientProtocol;
      myContractReference->ClientProtocol->Credentials = CredentialCache::DefaultCredentials;
      
      // Get the service description.
      ServiceDescription^ myContract = myContractReference->Contract;
      
      // Create the service description file.
      myContract->Write( "MyService1.wsdl" );
      Console::WriteLine( "The WSDL file created is MyService1.wsdl" );
      discoStream->Close();
   }
   catch ( Exception^ ex ) 
   {
      Console::WriteLine( "Exception: {0}", ex->Message );
   }
}
class MyClass1
{
    public static void main(String[] args)
    {
        try {
            // Create the file stream.
            FileStream discoStream = new FileStream("Service1_JSL.disco", 
                FileMode.Open);

            // Create the discovery document.
            DiscoveryDocument myDiscoveryDocument = DiscoveryDocument.
                Read(discoStream);

            // Get the first ContractReference in the collection.
            ContractReference myContractReference = (ContractReference)
                myDiscoveryDocument.get_References().get_Item(0);

            // Set the client protocol.
            myContractReference.set_ClientProtocol(
                new DiscoveryClientProtocol());
            myContractReference.get_ClientProtocol().set_Credentials(
                CredentialCache.get_DefaultCredentials());

            // Get the service description.
            ServiceDescription myContract = myContractReference.get_Contract();

            // Create the service description file.
            myContract.Write("MyService1.wsdl");
            Console.WriteLine("The WSDL file created is MyService1.wsdl");
            discoStream.Close();
        }
        catch (System.Exception ex) {
            Console.WriteLine("Exception: " + ex.get_Message());
        }
    } //main
} //MyClass1

Plattformen

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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ContractReference-Klasse
ContractReference-Member
System.Web.Services.Discovery-Namespace
ServiceDescription-Klasse