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
- Наследование
Примеры
#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-адрес обычно указывает на документ обнаружения, который обычно имеет расширение имени файла диско. В документе обнаружения содержатся ссылки на сведения о существовании веб-служб XML. Эти ссылки могут ссылаться на описания служб, схемы языка определения схемы XML (XSD) или другие документы обнаружения. Этот класс представляет ссылку на описание службы.
В документе обнаружения ссылка на описание службы содержится в XML-элементе contractRef . Xml-элемент contractRef имеет два атрибута: ref и docRef. Элемент contractRef должен иметь пространство имен XML, соответствующее Namespace константе, в то время как refdocRef атрибуты помещаются в Ref и DocRef свойства.
Конструкторы
| Имя. | Описание |
|---|---|
| ContractReference() |
Инициализирует новый экземпляр класса с помощью значений ContractReference по умолчанию. |
| ContractReference(String, String) |
Инициализирует новый экземпляр ContractReference класса, используя предоставленные ссылки на описание службы и веб-службу XML, реализующие описание службы. |
| ContractReference(String) |
Инициализирует новый экземпляр ContractReference класса, используя указанную ссылку на описание службы. |
Поля
| Имя. | Описание |
|---|---|
| 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. |