DiscoveryDocument Třída
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Představuje dokument zjišťování. Tuto třídu nelze zdědit.
public ref class DiscoveryDocument sealed
public sealed class DiscoveryDocument
type DiscoveryDocument = class
Public NotInheritable Class DiscoveryDocument
- Dědičnost
-
DiscoveryDocument
Příklady
Následující příklad kódu načte dokument zjišťování ze souboru pomocí Read souboru a zapíše ho zpět do souboru pomocí Write metody.
#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 = gcnew DiscoveryDocument;
// Create an XmlTextReader with the sample file.
XmlTextReader^ myXmlTextReader = gcnew XmlTextReader( "http://localhost/example_cs.disco" );
// Read the given XmlTextReader.
myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader );
// Write the DiscoveryDocument into the 'TextWriter'.
FileStream^ myFileStream = gcnew FileStream( "log.txt",FileMode::OpenOrCreate,FileAccess::Write );
StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream );
myDiscoveryDocument->Write( myStreamWriter );
myStreamWriter->Flush();
myStreamWriter->Close();
// Display the contents of the DiscoveryDocument onto the console.
FileStream^ myFileStream1 = gcnew FileStream( "log.txt",FileMode::OpenOrCreate,FileAccess::Read );
StreamReader^ myStreamReader = gcnew 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 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);
}
}
}
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
End Class
Poznámky
Zjišťování webových služeb XML zahrnuje zjišťování dostupných webových služeb XML s adresou URL. Adresa URL obvykle odkazuje na dokument zjišťování, který má obvykle příponu názvu souboru .disco. Dokument zjišťování, což je dokument XML, obsahuje odkazy na informace o existenci webových služeb XML, jako je popis služby, schéma jazyka XSD (XML Schema Definition) nebo jiný dokument zjišťování. Tato třída představuje obsah dokumentu zjišťování; References kde vlastnost obsahuje seznam odkazů obsažených v dokumentu zjišťování.
Konstruktory
| Name | Description |
|---|---|
| DiscoveryDocument() |
Inicializuje novou instanci DiscoveryDocument třídy. |
Pole
| Name | Description |
|---|---|
| Namespace |
Obor názvů elementu XML zjišťování dokumentu zjišťování |
Vlastnosti
| Name | Description |
|---|---|
| References |
Seznam odkazů obsažených v dokumentu zjišťování |
Metody
| Name | Description |
|---|---|
| CanRead(XmlReader) |
Vrátí hodnotu označující, zda lze předat XmlReader deserializovat do DiscoveryDocument. |
| Equals(Object) |
Určuje, zda je zadaný objekt roven aktuálnímu objektu. (Zděděno od Object) |
| GetHashCode() |
Slouží jako výchozí funkce hash. (Zděděno od Object) |
| GetType() |
Získá Type aktuální instance. (Zděděno od Object) |
| MemberwiseClone() |
Vytvoří mělkou kopii aktuálního Object. (Zděděno od Object) |
| Read(Stream) |
Přečte a vrátí DiscoveryDocument z předaného Stream. |
| Read(TextReader) |
Přečte a vrátí DiscoveryDocument z předaného TextReader. |
| Read(XmlReader) |
Přečte a vrátí DiscoveryDocument z předaného XmlReader. |
| ToString() |
Vrátí řetězec, který představuje aktuální objekt. (Zděděno od Object) |
| Write(Stream) |
Zapíše to DiscoveryDocument do předaného Stream. |
| Write(TextWriter) |
Zapíše to DiscoveryDocument do předaného TextWriter. |
| Write(XmlWriter) |
Zapíše to DiscoveryDocument do předaného XmlWriter. |