Export (0) Print
Expand All

DiscoveryDocument Class

Represents a discovery document. This class cannot be inherited.

For a list of all members of this type, see DiscoveryDocument Members.

System.Object
   System.Web.Services.Discovery.DiscoveryDocument

[Visual Basic]
NotInheritable Public Class DiscoveryDocument
[C#]
public sealed class DiscoveryDocument
[C++]
public __gc __sealed class DiscoveryDocument
[JScript]
public class DiscoveryDocument

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

XML Web services discovery involves discovering the available XML Web services, given an URL. The URL typically points to a discovery document, which usually has a .disco file name extension. The discovery document, which is an XML document, contains references to information about the existance of XML Web services, such as a service description, XML Schema Definition (XSD) language schema, or another discovery document. This class represents the contents of the discovery document; where the References property contains a list of the references contained within the discovery document.

Example

[Visual Basic, C#, C++] The following code example reads a discovery document from a file using the Read and writes it back out to file using the Write method.

[Visual Basic] 
Imports System
Imports System.Xml
Imports System.IO
Imports System.Web.Services.Discovery
Imports System.Collections


Public Class DiscoveryDocument_Example
   
   Shared Sub Main()
      Try
         ' Create an object of the 'DiscoveryDocument'.
         Dim myDiscoveryDocument As New DiscoveryDocument()
         
         ' Create an XmlTextReader with the sample file.
         Dim myXmlTextReader As New XmlTextReader("http://localhost/example_vb.disco")
         
         ' Read the given XmlTextReader.
         myDiscoveryDocument = DiscoveryDocument.Read(myXmlTextReader)
         
         ' Write the DiscoveryDocument into the 'TextWriter'.
         Dim myFileStream As New FileStream("log.txt", FileMode.OpenOrCreate, FileAccess.Write)
         Dim myStreamWriter As New StreamWriter(myFileStream)
         myDiscoveryDocument.Write(myStreamWriter)

         myStreamWriter.Flush()
         myStreamWriter.Close()
         ' Display the contents of the DiscoveryDocument onto the console.
         Dim myFileStream1 As New FileStream("log.txt", FileMode.OpenOrCreate, FileAccess.Read)
         Dim myStreamReader As New StreamReader(myFileStream1)
         
         ' Set the file pointer to the begin.
         myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin)
         Console.WriteLine("The contents of the DiscoveryDocument are-")
         While myStreamReader.Peek() > - 1
            Console.WriteLine(myStreamReader.ReadLine())
         End While
         myStreamReader.Close()
      Catch e As Exception
         Console.WriteLine("Exception raised : {0}", e.Message.ToString())
      End Try
   End Sub 'Main
End Class 'DiscoveryDocument_Example

[C#] 
using System;
using System.Xml;
using System.IO;
using System.Web.Services.Discovery;
using System.Collections;

public class DiscoveryDocument_Example
{
   static void Main()
   {
      try
      {
         // Create an object of the 'DiscoveryDocument'.
         DiscoveryDocument myDiscoveryDocument = new DiscoveryDocument();

         // Create an XmlTextReader with the sample file.
         XmlTextReader myXmlTextReader = new 
            XmlTextReader( "http://localhost/example_cs.disco" );

         // Read the given XmlTextReader.
         myDiscoveryDocument = DiscoveryDocument.Read( myXmlTextReader );

         // Write the DiscoveryDocument into the 'TextWriter'.
         FileStream myFileStream = new 
                  FileStream( "log.txt", FileMode.OpenOrCreate, FileAccess.Write );
         StreamWriter myStreamWriter = new StreamWriter( myFileStream );
         myDiscoveryDocument.Write( myStreamWriter );

         myStreamWriter.Flush();  
         myStreamWriter.Close(); 

         // Display the contents of the DiscoveryDocument onto the console.
         FileStream myFileStream1 = new
                        FileStream( "log.txt", FileMode.OpenOrCreate, FileAccess.Read );
         StreamReader myStreamReader = new StreamReader( myFileStream1 );        

         // Set the file pointer to the begin.
         myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin); 
         Console.WriteLine( "The contents of the DiscoveryDocument are-" );
         while ( myStreamReader.Peek() > -1 ) 
         {
            Console.WriteLine( myStreamReader.ReadLine() );
         }
         myStreamReader.Close();
      }
      catch( Exception e )
      {
         Console.WriteLine( "Exception raised : {0}", e.Message);
      }
   }
}

[C++] 
#using <mscorlib.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Xml;
using namespace System::IO;
using namespace System::Web::Services::Discovery;
using namespace System::Collections;

int main()
{
   try 
   {
      // Create an Object* of the 'DiscoveryDocument'.
      DiscoveryDocument* myDiscoveryDocument = new DiscoveryDocument();

      // Create an XmlTextReader with the sample file.
      XmlTextReader* myXmlTextReader = new XmlTextReader(S"http://localhost/example_cs.disco");

      // Read the given XmlTextReader.
      myDiscoveryDocument = DiscoveryDocument::Read(myXmlTextReader);

      // Write the DiscoveryDocument into the 'TextWriter'.
      FileStream* myFileStream = new FileStream(S"log.txt", FileMode::OpenOrCreate, FileAccess::Write);
      StreamWriter* myStreamWriter = new StreamWriter(myFileStream);
      myDiscoveryDocument->Write(myStreamWriter);

      myStreamWriter->Flush();  
      myStreamWriter->Close(); 

      // Display the contents of the DiscoveryDocument onto the console.
      FileStream* myFileStream1 = new FileStream(S"log.txt", FileMode::OpenOrCreate, FileAccess::Read);
      StreamReader* myStreamReader = new StreamReader(myFileStream1);        

      // Set the file pointer to the begin.
      myStreamReader->BaseStream -> Seek(0, SeekOrigin::Begin); 
      Console::WriteLine(S"The contents of the DiscoveryDocument are-");
      while (myStreamReader->Peek() > -1) {
         Console::WriteLine(myStreamReader->ReadLine());
      }
      myStreamReader->Close();
   } 
   catch (Exception* e) 
   {
      Console::WriteLine(S"Exception raised : {0}", e -> Message);
   }
}

[Visual Basic, C#, C++]

[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

Namespace: System.Web.Services.Discovery

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

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

See Also

DiscoveryDocument Members | System.Web.Services.Discovery Namespace | DiscoveryClientProtocol

Show:
© 2014 Microsoft