This documentation is archived and is not being maintained.

ContractReference.ReadDocument Method

Reads the service description from the passed Stream and returns the service description.

[Visual Basic]
Overrides Public Function ReadDocument( _
   ByVal stream As Stream _
) As Object
[C#]
public override object ReadDocument(
 Stream stream
);
[C++]
public: Object* ReadDocument(
 Stream* stream
);
[JScript]
public override function ReadDocument(
   stream : Stream
) : Object;

Parameters

stream
Stream containing the service description.

Return Value

A ServiceDescription containing the contents of the referenced service description.

Example

[Visual Basic] 
Class MyClass1
   
   Shared Sub Main()
      Try
         ' Create the file stream.
         Dim wsdlStream As _
             New FileStream("MyService1_vb.wsdl", FileMode.Open)
         Dim myContractReference As New ContractReference()

         ' Read the service description from the passed stream.
         Dim myServiceDescription As ServiceDescription = _
             CType(myContractReference.ReadDocument(wsdlStream), _
             ServiceDescription)
         Console.Write(("Target Namesapce for the service description is: " _
             + myServiceDescription.TargetNamespace))
         wsdlStream.Close()

      Catch e As Exception
         Console.WriteLine(("Exception: " + e.Message))
      End Try
   End Sub 'Main
End Class 'MyClass1

[C#] 
class MyClass1
{
   static void Main()
   {
      try
      {
         // Create the file stream.
         FileStream wsdlStream = new FileStream("MyService1_cs.wsdl",
             FileMode.Open);
         ContractReference myContractReference=new ContractReference();

         // Read the service description from the passed stream.
         ServiceDescription myServiceDescription=
             (ServiceDescription)myContractReference.ReadDocument(wsdlStream);
         Console.Write("Target Namespace for the service description is: "
             + myServiceDescription.TargetNamespace);
         wsdlStream.Close();
      }
      catch(Exception e)
      {
         Console.WriteLine("Exception: "+e.Message);
      }
   }
}

[C++] 
int main() {
   try {
      // Create the file stream.
      FileStream* wsdlStream = new FileStream(S"MyService1_cs.wsdl",
         FileMode::Open);
      ContractReference* myContractReference = new ContractReference();

      // Read the service description from the passed stream.
      ServiceDescription* myServiceDescription=
         dynamic_cast<ServiceDescription*>(myContractReference->ReadDocument(wsdlStream));
      Console::Write(S"Target Namespace for the service description is: {0}",
         myServiceDescription->TargetNamespace);
      wsdlStream->Close();
   } catch (Exception* e) {
      Console::WriteLine(S"Exception: {0}", e->Message);
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter 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 | Stream | ServiceDescription | DiscoveryClientProtocol | ReadAll

Show: