共用方式為


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

適用於

另請參閱