ContractReference.Contract Property
.NET Framework 3.0
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)
Assembly: System.Web.Services (in system.web.services.dll)
| Exception type | Condition |
|---|---|
|
ClientProtocol property is a null reference (Nothing in Visual Basic). | |
|
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 ); } }
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
Windows 98, Windows Server 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
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: