Export (0) Print
Expand All

DiscoveryDocument.Read Method (TextReader)

Reads and returns a DiscoveryDocument from the passed TextReader.

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

public static DiscoveryDocument Read(
	TextReader reader


Type: System.IO.TextReader

The TextReader from which to read the DiscoveryDocument.

Return Value

Type: System.Web.Services.Discovery.DiscoveryDocument
A DiscoveryDocument containing the contents of a discovery document from the passed TextReader.

The following code example reads the discovery document from " http://localhost/example_Write2_cs.vsdisco " into a XmlTextReader.

// Create a DiscoveryDocument.
DiscoveryDocument myDiscoveryDocument = new DiscoveryDocument();

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

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

FileStream myFileStream = new
   FileStream( "log.txt", FileMode.OpenOrCreate, FileAccess.Write );
StreamWriter myStreamWriter = new StreamWriter( myFileStream );

XmlTextWriter myXmlTextWriter = new XmlTextWriter( myStreamWriter );
myDiscoveryDocument.Write( myXmlTextWriter );


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

// Set the file pointer to the beginning.
myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin);
Console.WriteLine( "The contents of the DiscoveryDocument are:" );
while ( myStreamReader.Peek() > -1 )
   Console.WriteLine( myStreamReader.ReadLine() );

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft