Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DiscoveryDocument Class

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

The DiscoveryDocument type exposes the following members.

Public methodDiscoveryDocumentInitializes a new instance of the DiscoveryDocument class.

Public propertyReferencesA list of references contained within the discovery document.

Public methodStatic memberCanReadReturns a value indicating whether the passed XmlReader can be deserialized into a DiscoveryDocument.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberRead(Stream)Reads and returns a DiscoveryDocument from the passed Stream.
Public methodStatic memberRead(TextReader)Reads and returns a DiscoveryDocument from the passed TextReader.
Public methodStatic memberRead(XmlReader)Reads and returns a DiscoveryDocument from the passed XmlReader.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWrite(Stream)Writes this DiscoveryDocument into the passed Stream.
Public methodWrite(TextWriter)Writes this DiscoveryDocument into the passed TextWriter.
Public methodWrite(XmlWriter)Writes this DiscoveryDocument into the passed XmlWriter.

Public fieldStatic memberNamespaceNamespace of the discovery XML element of a discovery document.

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()
         // 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 );


         // 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() );
      catch( Exception e )
         Console.WriteLine( "Exception raised : {0}", e.Message);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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