Export (0) Print
Expand All
0 out of 1 rated this helpful - 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
public final class DiscoveryDocument
public final class DiscoveryDocument
Not applicable.

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);
      }
   }
}

import System.*;
import System.Xml.*;
import System.IO.*;
import System.Web.Services.Discovery.*;
import System.Collections.*;

public class DiscoveryDocumentExample
{
    public static void main(String[] args)
    {
        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_jsl.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.get_BaseStream().Seek(0, SeekOrigin.Begin);
            Console.WriteLine("The contents of the DiscoveryDocument are-");
            while (myStreamReader.Peek() > -1) {
                Console.WriteLine(myStreamReader.ReadLine());
            }
            myStreamReader.Close();
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception raised : {0}", e.get_Message());
        }
    } //main
} //DiscoveryDocumentExample

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 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.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.