Upravit

Sdílet prostřednictvím


DiscoveryDocumentReference Class

Definition

Represents a reference to a discovery document. This class cannot be inherited.

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
Inheritance
DiscoveryDocumentReference

Examples

#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

Remarks

XML Web services discovery involves discovering the available XML Web services given an URL. The URL typically points to a discovery document, which usually has a.disco file name extension. The discovery document contains references to information about the existence of XML Web services, such as Service Descriptions, XML Schema Definition language (XSD) schemas, or other discovery documents. This class represents a reference to a discovery document.

Constructors

DiscoveryDocumentReference()

Initializes a new instance of the DiscoveryDocumentReference class.

DiscoveryDocumentReference(String)

Initializes a new instance of the DiscoveryDocumentReference class, setting the Ref property to the value of href.

Properties

ClientProtocol

Gets or sets the instance of DiscoveryClientProtocol used in a discovery process.

(Inherited from DiscoveryReference)
DefaultFilename

Gets the name of the default file to use when saving the referenced discovery document.

Document

Gets the contents of the referenced discovery document as a DiscoveryDocument object.

Ref

Gets or sets the reference to a discovery document.

Url

Gets or sets the URL of the referenced discovery document.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ReadDocument(Stream)

Reads and returns the discovery document from the passed Stream.

Resolve()

Downloads the referenced document at Url to resolve whether the referenced document is valid.

(Inherited from DiscoveryReference)
Resolve(String, Stream)

Resolves whether the referenced document is valid.

(Inherited from DiscoveryReference)
ResolveAll()

Verifies that all referenced documents within the discovery document are valid.

ToString()

Returns a string that represents the current object.

(Inherited from Object)
WriteDocument(Object, Stream)

Writes the passed DiscoveryDocument into the passed Stream.

Applies to

See also