ContractReference.Contract Property

Definition

Gets a ServiceDescription object representing the service description.

C#
public System.Web.Services.Description.ServiceDescription Contract { get; }

Property Value

A ServiceDescription object representing the service description.

Exceptions

The Documents property of ClientProtocol does not contain a discovery document with an URL of Url.

Examples

C#
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);
      }
   }
}

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also