ContractReference Třída

Definice

Představuje odkaz v dokumentu zjišťování na popis služby.

public ref class ContractReference : System::Web::Services::Discovery::DiscoveryReference
public class ContractReference : System.Web.Services.Discovery.DiscoveryReference
type ContractReference = class
    inherit DiscoveryReference
Public Class ContractReference
Inherits DiscoveryReference
Dědičnost
ContractReference

Příklady

#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;
int main()
{
   try
   {
      
      // Get a DiscoveryDocument.
      DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument;
      
      // Get a ContractReference.
      ContractReference^ myContractReference = gcnew ContractReference;
      
      // Set the URL to the referenced service description.
      myContractReference->Ref = "http://localhost/service1.asmx?wsdl";
      
      // Set the URL for an XML Web service implementing the service
      // description.
      myContractReference->DocRef = "http://localhost/service1.asmx";
      SoapBinding^ myBinding = gcnew SoapBinding;
      myBinding->Binding = gcnew XmlQualifiedName( "q1:Service1Soap" );
      myBinding->Address = "http://localhost/service1.asmx";
      
      // Add myContractReference to the list of references contained
      // in the discovery document.
      myDiscoveryDocument->References->Add( myContractReference );
      
      // Add Binding to the references collection.
      myDiscoveryDocument->References->Add( myBinding );
      
      // Open or create a file for writing.
      FileStream^ myFileStream = gcnew FileStream( "Service1.disco",FileMode::OpenOrCreate,FileAccess::Write );
      StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream );
      
      // Write myDiscoveryDocument into the passed stream.
      myDiscoveryDocument->Write( myStreamWriter );
      Console::WriteLine( "The Service1.disco is generated." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Error is {0}", e->Message );
   }

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

public class MyContractReference
{
   static void Main()
   {
      try
      {
         // Get a DiscoveryDocument.
         DiscoveryDocument myDiscoveryDocument = new  DiscoveryDocument();

         // Get a ContractReference.
         ContractReference myContractReference = new ContractReference();

         // Set the URL to the referenced service description.
         myContractReference.Ref = "http://localhost/service1.asmx?wsdl";

         // Set the URL for an XML Web service implementing the service
         // description.
         myContractReference.DocRef = "http://localhost/service1.asmx";
         SoapBinding myBinding = new SoapBinding();
         myBinding.Binding = new XmlQualifiedName("q1:Service1Soap");
         myBinding.Address = "http://localhost/service1.asmx";

         // Add myContractReference to the list of references contained
         // in the discovery document.
         myDiscoveryDocument.References.Add(myContractReference);

         // Add Binding to the references collection.
         myDiscoveryDocument.References.Add(myBinding);

         // Open or create a file for writing.
         FileStream myFileStream = new FileStream("Service1.disco",
             FileMode.OpenOrCreate, FileAccess.Write );
         StreamWriter myStreamWriter = new StreamWriter( myFileStream );

         // Write myDiscoveryDocument into the passed stream.
         myDiscoveryDocument.Write( myStreamWriter );
         Console.WriteLine("The Service1.disco is generated.");
      }
      catch(Exception e)
      {
         Console.WriteLine("Error is "+ e.Message);
      }
   }
}
Imports System.Xml
Imports System.IO
Imports System.Web.Services.Discovery

Public Class MyContractReference
   Shared Sub Main()
      Try
         ' Get a 'DiscoveryDocument' object.
         Dim myDiscoveryDocument As New DiscoveryDocument()
         ' Get a 'ContractReference' object.
         Dim myContractReference As New ContractReference()
         ' Set the URL to the referenced service description.
         myContractReference.Ref = "http://localhost/service1.asmx?wsdl"
         ' Set the URL for a XML Web service implementing the service
         ' description .
         myContractReference.DocRef = "http://localhost/service1.asmx"
         Dim myBinding As New SoapBinding()
         myBinding.Binding = New XmlQualifiedName("q1:Service1Soap")
         myBinding.Address = "http://localhost/service1.asmx"
         ' Add 'myContractReference' to the list of references contained 
         ' within the discovery document.
         myDiscoveryDocument.References.Add(myContractReference)
         ' Add 'Binding' to referenceCollection.
         myDiscoveryDocument.References.Add(myBinding)
         ' Open or create a file for writing .
         Dim myFileStream As New FileStream("Service1.disco", FileMode.OpenOrCreate, FileAccess.Write)
         Dim myStreamWriter As New StreamWriter(myFileStream)
         ' Write 'myDiscoveryDocument' into the passed stream.
         myDiscoveryDocument.Write(myStreamWriter)
         Console.WriteLine("The 'Service1.disco' is generated.")
      Catch e As Exception
         Console.WriteLine("Error is" + e.Message)
      End Try
   End Sub
End Class

Poznámky

Zjišťování webových služeb XML zahrnuje zjišťování dostupných webových služeb s adresou URL. Adresa URL obvykle odkazuje na dokument zjišťování, který má obvykle příponu názvu souboru .disco. V dokumentu zjišťování jsou odkazy na informace o existenci webových služeb XML. Tyto odkazy můžou odkazovat na popisy služeb, schémata XSD (XML Schema Definition Language) nebo jiné dokumenty zjišťování. Tato třída představuje odkaz na popis služby.

V dokumentu zjišťování je odkaz na popis služby obsažen v elementu contractRef XML. Element contractRef XML má dva atributy: ref a docRef. Element contractRef musí mít obor názvů XML odpovídající konstantě Namespace , zatímco ref atributy jsou docRef umístěny v objektech Ref a DocRef vlastnostech.

Konstruktory

Name Description
ContractReference()

Inicializuje novou instanci ContractReference třídy pomocí výchozích hodnot.

ContractReference(String, String)

Inicializuje novou instanci ContractReference třídy pomocí zadaných odkazů na popis služby a webové služby XML implementuje popis služby.

ContractReference(String)

Inicializuje novou instanci ContractReference třídy pomocí zadaného odkazu na popis služby.

Pole

Name Description
Namespace

Obor názvů XML pro odkazy na popis služby v dokumentech zjišťování

Vlastnosti

Name Description
ClientProtocol

Získá nebo nastaví instanci DiscoveryClientProtocol použité v procesu zjišťování.

(Zděděno od DiscoveryReference)
Contract

ServiceDescription Získá objekt představující popis služby.

DefaultFilename

Získá název souboru, který se má použít ve výchozím nastavení při uložení popisu odkazované služby.

DocRef

Získá nebo nastaví adresu URL webové služby XML implementuje popis služby odkazovaný ve Ref vlastnosti.

Ref

Získá nebo nastaví adresu URL na popis odkazované služby.

Url

Získá nebo nastaví adresu URL odkazovaného popisu služby.

Metody

Name Description
Equals(Object)

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Získá Type aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ReadDocument(Stream)

Přečte popis služby z předaného Stream a vrátí popis služby.

Resolve()

Stáhne odkazovaný dokument Url a vyřeší, jestli je odkazovaný dokument platný.

(Zděděno od DiscoveryReference)
Resolve(String, Stream)

Řeší, jestli je odkazovaný dokument platný.

ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)
WriteDocument(Object, Stream)

Zapíše předaný popis služby do předaného .Stream

Platí pro

Viz také