This documentation is archived and is not being maintained.
ContractReference::Contract Property
Visual Studio 2008
Gets a System.Web.Services.Description::ServiceDescription object representing the service description.
Assembly: System.Web.Services (in System.Web.Services.dll)
Property Value
Type: System.Web.Services.Description::ServiceDescriptionA System.Web.Services.Description::ServiceDescription object representing the service description.
| Exception | Condition |
|---|---|
| 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 ); } }
int main()
{
try
{
// Create the file stream.
FileStream* discoStream =
new FileStream(S"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->Item[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(S"MyService1.wsdl");
Console::WriteLine(S"The WSDL file created is MyService1.wsdl");
discoStream->Close();
}
catch(Exception* ex)
{
Console::WriteLine(S"Exception: {0}", ex->Message);
}
}
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: