DiscoveryDocumentReference 类

定义

表示对发现文档的引用。 此类不能被继承。

public ref class DiscoveryDocumentReference sealed : System::Web::Services::Discovery::DiscoveryReference
public sealed class DiscoveryDocumentReference : System.Web.Services.Discovery.DiscoveryReference
type DiscoveryDocumentReference = class
    inherit DiscoveryReference
Public NotInheritable Class DiscoveryDocumentReference
Inherits DiscoveryReference
继承
DiscoveryDocumentReference

示例

#using <System.Web.Services.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::Xml;
using namespace System::Web::Services::Discovery;
using namespace System::IO;
using namespace System::Collections;
int main()
{
   try
   {
      DiscoveryDocument^ myDiscoveryDocument;
      XmlTextReader^ myXmlTextReader = gcnew XmlTextReader( "http://localhost/Sample_cs::vsdisco" );
      myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader );
      
      // Create a new instance of DiscoveryDocumentReference.
      DiscoveryDocumentReference^ myDiscoveryDocumentReference = gcnew DiscoveryDocumentReference;
      
      FileStream^ myFileStream = gcnew FileStream( "Temp::vsdisco",FileMode::OpenOrCreate,FileAccess::Write );
      myDiscoveryDocumentReference->WriteDocument( myDiscoveryDocument, myFileStream );
      myFileStream->Close();
      
      FileStream^ myFileStream1 = gcnew FileStream( "Temp::vsdisco",FileMode::OpenOrCreate,FileAccess::Read );
      StreamReader^ myStreamReader = gcnew StreamReader( myFileStream1 );
      
      // Initialize the file pointer.
      myStreamReader->BaseStream->Seek( 0, SeekOrigin::Begin );
      Console::WriteLine( "The contents of the discovery document are: \n" );
      while ( myStreamReader->Peek() > -1 )
      {
         
         // Display the contents of the discovery document.
         Console::WriteLine( myStreamReader->ReadLine() );
      }
      myStreamReader->Close();
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }

}
using System;
using System.Xml;
using System.Web.Services.Discovery;
using System.IO;
using System.Collections;

public class DiscoveryDocumentReference_ctor_WriteDocument
{
    public static void Main()
    {
        try
        {
            DiscoveryDocument myDiscoveryDocument;
            XmlTextReader myXmlTextReader =
                new XmlTextReader("http://localhost/Sample_cs.vsdisco");
            myDiscoveryDocument = DiscoveryDocument.Read(myXmlTextReader);

            // Create a new instance of DiscoveryDocumentReference.
            DiscoveryDocumentReference myDiscoveryDocumentReference =
                new DiscoveryDocumentReference();
            FileStream myFileStream = new FileStream("Temp.vsdisco",
                FileMode.OpenOrCreate, FileAccess.Write);
            myDiscoveryDocumentReference.WriteDocument(
                myDiscoveryDocument, myFileStream);
            myFileStream.Close();

            FileStream myFileStream1 = new FileStream("Temp.vsdisco",
                FileMode.OpenOrCreate, FileAccess.Read);
            StreamReader myStreamReader = new StreamReader(myFileStream1);

            // Initialize the file pointer.
            myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin);
            Console.WriteLine("The contents of the discovery document are: \n");
            while(myStreamReader.Peek() > -1)
            {
                // Display the contents of the discovery document.
                Console.WriteLine(myStreamReader.ReadLine());
            }
            myStreamReader.Close();
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception: {0}", e.Message);
        }
    }
}
Imports System.Xml
Imports System.Web.Services.Discovery
Imports System.IO
Imports System.Collections

Public Class DiscoveryDocumentReference_ctor_WriteDocument

    Public Shared Sub Main()
        Try
            Dim myDiscoveryDocument As DiscoveryDocument
            Dim myXmlTextReader As _
                 New XmlTextReader("http://localhost/Sample_vb.vsdisco")
            myDiscoveryDocument = DiscoveryDocument.Read(myXmlTextReader)

            ' Create a new instance of DiscoveryDocumentReference.
            Dim myDiscoveryDocumentReference As _
                New DiscoveryDocumentReference()
            Dim myFileStream As New FileStream("Temp.vsdisco", _
                 FileMode.OpenOrCreate, FileAccess.Write)
            myDiscoveryDocumentReference.WriteDocument( _
                 myDiscoveryDocument, myFileStream)
            myFileStream.Close()

            Dim myFileStream1 As New FileStream("Temp.vsdisco", _
                FileMode.OpenOrCreate, FileAccess.Read)
            Dim myStreamReader As New StreamReader(myFileStream1)

            ' Initialize the file pointer.
            myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin)
            Console.WriteLine("The contents of the discovery document are: " _
                & ControlChars.NewLine)
            While myStreamReader.Peek() > - 1
                ' Display the contents of the discovery document.
                Console.WriteLine(myStreamReader.ReadLine())
            End While
            myStreamReader.Close()
        Catch e As Exception
            Console.WriteLine("Exception: {0}", e.Message.ToString())
        End Try
    End Sub
End Class

注解

XML Web 服务发现涉及发现给定 URL 的可用 XML Web 服务。 URL 通常指向发现文档,该文档通常具有.disco 文件扩展名。 发现文档包含有关 XML Web 服务存在的信息(如服务说明、XML 架构定义语言 (XSD) 架构或其他发现文档)的引用。 此类表示对发现文档的引用。

构造函数

DiscoveryDocumentReference()

初始化 DiscoveryDocumentReference 类的新实例。

DiscoveryDocumentReference(String)

初始化 DiscoveryDocumentReference 类的新实例,将 Ref 属性设置为 href 的值。

属性

ClientProtocol

获取或设置在发现过程中使用的 DiscoveryClientProtocol 的实例。

(继承自 DiscoveryReference)
DefaultFilename

获取保存所引用的发现文档时要使用的默认文件的名称。

Document

将所引用的发现文档的内容作为 DiscoveryDocument 对象获取。

Ref

获取或设置对发现文档的引用。

Url

获取或设置所引用的发现文档的 URL。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ReadDocument(Stream)

从传递的 Stream 读取并返回发现文档。

Resolve()

下载 Url 处的引用文档以解析引用的文档是否有效。

(继承自 DiscoveryReference)
Resolve(String, Stream)

解析引用的文档是否有效。

(继承自 DiscoveryReference)
ResolveAll()

验证发现文档中的所有引用文档是否有效。

ToString()

返回表示当前对象的字符串。

(继承自 Object)
WriteDocument(Object, Stream)

将传递的 DiscoveryDocument 写入传递的 Stream

适用于

另请参阅