This topic has not yet been rated - Rate this topic

DiscoveryDocument Class

Represents a discovery document. This class cannot be inherited.

Namespace:  System.Web.Services.Discovery
Assembly:  System.Web.Services (in System.Web.Services.dll)
public sealed class DiscoveryDocument

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.

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.

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);
      }
   }
}
#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);
   }
}
System.Object
  System.Web.Services.Discovery.DiscoveryDocument
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.