DiscoveryDocument 类

定义

表示发现文档。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
继承
DiscoveryDocument

示例

下面的代码示例使用从文件中读取一个发现文档 Read ,并使用方法将其写回到文件中 WriteThe 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

注解

给定 URL,XML Web services 发现涉及到发现可用的 XML Web services。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 services 存在的信息的引用,如服务说明、XML 架构定义 (XSD) language Schema 或其他发现文档。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 类的新实例。Initializes a new instance of the DiscoveryDocument class.

字段

Namespace

发现文档的发现 XML 元素的命名空间。Namespace of the discovery XML element of a discovery document.

属性

References

包含在发现文档中的引用的列表。A list of references contained within the discovery document.

方法

CanRead(XmlReader)

返回一个值,该值指示传递的 XmlReader 是否可以反序列化为 DiscoveryDocumentReturns a value indicating whether the passed XmlReader can be deserialized into a DiscoveryDocument.

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Read(Stream)

从所传递的 DiscoveryDocument 中读取和返回一个 StreamReads and returns a DiscoveryDocument from the passed Stream.

Read(TextReader)

从所传递的 DiscoveryDocument 中读取和返回一个 TextReaderReads and returns a DiscoveryDocument from the passed TextReader.

Read(XmlReader)

从所传递的 DiscoveryDocument 中读取和返回一个 XmlReaderReads and returns a DiscoveryDocument from the passed XmlReader.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)
Write(Stream)

将此 DiscoveryDocument 写入所传递的 StreamWrites this DiscoveryDocument into the passed Stream.

Write(TextWriter)

将此 DiscoveryDocument 写入所传递的 TextWriterWrites this DiscoveryDocument into the passed TextWriter.

Write(XmlWriter)

将此 DiscoveryDocument 写入所传递的 XmlWriterWrites this DiscoveryDocument into the passed XmlWriter.

适用于

另请参阅