Share via


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 zadaných adresou URL. Adresa URL obvykle odkazuje na dokument zjišťování, který má obvykle příponu názvu souboru a.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 jazyka 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 a docRef jsou umístěny ve Ref vlastnostech a DocRef .

Konstruktory

ContractReference()

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

ContractReference(String)

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

ContractReference(String, String)

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

Pole

Namespace

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

Vlastnosti

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 ukládání odkazovaného popisu 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 pro odkazované popis služby.

Metody

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

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

Slouží jako výchozí hashovací funkce.

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

Získá aktuální Type instanci.

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

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

(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 na adrese a Url vyřeší tak, 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ředávaného Streamsouboru .

Platí pro

Viz také