DiscoveryDocument DiscoveryDocument DiscoveryDocument DiscoveryDocument Class

定義

表示探索 (Discovery) 文件。Represents a discovery document. 這個類別無法被繼承。This class cannot be inherited.

public ref class DiscoveryDocument sealed
public sealed class DiscoveryDocument
type DiscoveryDocument = class
Public NotInheritable Class DiscoveryDocument
繼承
DiscoveryDocumentDiscoveryDocumentDiscoveryDocumentDiscoveryDocument

範例

下列程式碼範例會使用Read從檔案讀取探索檔,並Write使用方法將它寫回檔案。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.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 'DiscoveryDocument_Example

備註

XML Web Service 探索包含探索可用的 XML Web Service (提供 URL)。XML Web services discovery involves discovering the available XML Web services, given an URL. URL 通常會指向探索檔,其通常會有 .disco 副檔名。The URL typically points to a discovery document, which usually has a .disco file name extension. 探索檔(也就是 XML 檔)包含有關 XML Web 服務是否存在的資訊,例如服務描述、XML 架構定義(XSD)語言架構或其他探索檔。The discovery document, which is an XML document, contains references to information about the existence of XML Web services, such as a service description, XML Schema Definition (XSD) language schema, or another discovery document. 此類別代表探索檔的內容;其中, References屬性包含探索檔中包含的參考清單。This class represents the contents of the discovery document; where the References property contains a list of the references contained within the discovery document.

建構函式

DiscoveryDocument() DiscoveryDocument() DiscoveryDocument() DiscoveryDocument()

初始化 DiscoveryDocument 類別的新執行個體。Initializes a new instance of the DiscoveryDocument class.

欄位

Namespace Namespace Namespace Namespace

探索文件的探索 XML 項目的命名空間。Namespace of the discovery XML element of a discovery document.

屬性

References References References References

內含於探索文件的參考清單。A list of references contained within the discovery document.

方法

CanRead(XmlReader) CanRead(XmlReader) CanRead(XmlReader) CanRead(XmlReader)

傳回值,指出傳遞的 XmlReader 是否可還原序列化為 DiscoveryDocumentReturns a value indicating whether the passed XmlReader can be deserialized into a DiscoveryDocument.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
Read(Stream) Read(Stream) Read(Stream) Read(Stream)

從傳遞的 DiscoveryDocument 讀取並傳回 StreamReads and returns a DiscoveryDocument from the passed Stream.

Read(TextReader) Read(TextReader) Read(TextReader) Read(TextReader)

從傳遞的 DiscoveryDocument 讀取並傳回 TextReaderReads and returns a DiscoveryDocument from the passed TextReader.

Read(XmlReader) Read(XmlReader) Read(XmlReader) Read(XmlReader)

從傳遞的 DiscoveryDocument 讀取並傳回 XmlReaderReads and returns a DiscoveryDocument from the passed XmlReader.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
Write(Stream) Write(Stream) Write(Stream) Write(Stream)

將這個 DiscoveryDocument 寫入至傳遞的 StreamWrites this DiscoveryDocument into the passed Stream.

Write(TextWriter) Write(TextWriter) Write(TextWriter) Write(TextWriter)

將這個 DiscoveryDocument 寫入至傳遞的 TextWriterWrites this DiscoveryDocument into the passed TextWriter.

Write(XmlWriter) Write(XmlWriter) Write(XmlWriter) Write(XmlWriter)

將這個 DiscoveryDocument 寫入至傳遞的 XmlWriterWrites this DiscoveryDocument into the passed XmlWriter.

適用於

另請參閱