This documentation is archived and is not being maintained.
ContractReference.Contract Property
.NET Framework 1.1
Gets a System.Web.Services.Description.ServiceDescription object representing the service description.
[Visual Basic] Public ReadOnly Property Contract As ServiceDescription [C#] public ServiceDescription Contract {get;} [C++] public: __property ServiceDescription* get_Contract(); [JScript] public function get Contract() : ServiceDescription;
Property Value
A System.Web.Services.Description.ServiceDescription object representing the service description.
Exceptions
| Exception Type | Condition |
|---|---|
| InvalidOperationException | ClientProtocol property is a null reference (Nothing in Visual Basic). |
| Exception | The Documents property of ClientProtocol does not contain a discovery document with an URL of Url. |
Example
[Visual Basic] 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 [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); } } } [C++] 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); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
ContractReference Class | ContractReference Members | System.Web.Services.Discovery Namespace | ServiceDescription
Show: