ContractReference Класс

Определение

Представляет ссылку в документе обнаружения на описание службы.

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
Наследование
ContractReference

Примеры

#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

Комментарии

Обнаружение веб-служб XML включает обнаружение доступных веб-служб по указанному URL-адресу. URL-адрес обычно указывает на документ обнаружения, который обычно имеет расширение файла disco. В документе обнаружения содержатся ссылки на сведения о существовании веб-служб XML. Эти ссылки могут ссылаться на описания служб, схемы языка определения схем XML (XSD) или другие документы обнаружения. Этот класс представляет ссылку на описание службы.

В документе обнаружения ссылка на описание службы содержится в XML-элементе contractRef . Xml-элемент contractRef имеет два атрибута: ref и docRef. Элемент contractRef должен иметь пространство имен XML, соответствующее константе Namespace , тогда как атрибуты ref и docRef размещаются в свойствах Ref и DocRef .

Конструкторы

ContractReference()

Инициализирует новый экземпляр класса ContractReference со значениями по умолчанию.

ContractReference(String)

Инициализирует новый экземпляр класса ContractReference с помощью указанной ссылки на описание службы.

ContractReference(String, String)

Инициализирует новый экземпляр класса ContractReference с помощью указанных ссылок на описание службы и веб-службу XML, реализующую это описание.

Поля

Namespace

Пространство имен XML для ссылок описания службы в документах обнаружения.

Свойства

ClientProtocol

Возвращает или задает экземпляр DiscoveryClientProtocol, используемый в процессе обнаружения.

(Унаследовано от DiscoveryReference)
Contract

Получает объект ServiceDescription, представляющий описание службы.

DefaultFilename

Получает имя файла для использования по умолчанию при сохранении описания службы, на которое указывает ссылка.

DocRef

Получает или задает URL-адрес для веб-службы XML, реализующей описание службы, на которое имеется ссылка в свойстве Ref.

Ref

Получает или задает URL-адрес для упоминаемого описания службы.

Url

Получает или задает URL-адрес для упоминаемого описания службы.

Методы

Equals(Object)

Определяет, равен ли указанный объект текущему объекту.

(Унаследовано от Object)
GetHashCode()

Служит хэш-функцией по умолчанию.

(Унаследовано от Object)
GetType()

Возвращает объект Type для текущего экземпляра.

(Унаследовано от Object)
MemberwiseClone()

Создает неполную копию текущего объекта Object.

(Унаследовано от Object)
ReadDocument(Stream)

Считывает описание службы из переданного класса Stream и возвращает описание службы.

Resolve()

Загружает документ, на который дается ссылка Url, для проверки его допустимости.

(Унаследовано от DiscoveryReference)
Resolve(String, Stream)

Определяет допустимость документа для ссылки.

ToString()

Возвращает строку, представляющую текущий объект.

(Унаследовано от Object)
WriteDocument(Object, Stream)

Записывает переданное описание службы в переданный класс Stream.

Применяется к

См. также раздел