This documentation is archived and is not being maintained.

ContractReference::Contract Property

Gets a System.Web.Services.Description::ServiceDescription object representing the service description.

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

public:
property ServiceDescription^ Contract {
	ServiceDescription^ get ();
}

ExceptionCondition
InvalidOperationException

ClientProtocol property is nullptr.

Exception

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


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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: