Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Stellt einen Verweis auf eine Dienstbeschreibung in einem Discoverydokument dar.
Namespace: System.Web.Services.Discovery
Assembly: System.Web.Services (in system.web.services.dll)
Syntax
'Declaration
Public Class ContractReference
Inherits DiscoveryReference
'Usage
Dim instance As ContractReference
public class ContractReference : DiscoveryReference
public ref class ContractReference : public DiscoveryReference
public class ContractReference extends DiscoveryReference
public class ContractReference extends DiscoveryReference
Hinweise
Das XML Web Services Discovery-Tool umfasst die Ermittlung der verfügbaren Webdienste anhand eines URL. Der URL verweist i. d. R. auf ein Discovery-Dokument, das normalerweise die Dateierweiterung .disco aufweist. In einem Discoverydokument befinden sich Verweise auf Informationen über das Vorhandensein von XML-Webdiensten. Diese Verweise können sich auf Dienstbeschreibungen, XSD-Schemas (XML Schema Definition) oder sonstige Discoverydokumente beziehen. Diese Klasse stellt einen Verweis auf eine Dienstbeschreibung dar.
In einem Discoverydokument ist ein Verweis auf eine Dienstbeschreibung in einem contractRef-XML-Element enthalten. Das contractRef-XML-Element verfügt über zwei Attribute: ref und docRef. Das contractRef-Element muss über einen XML-Namespace verfügen, der der Namespace-Konstanten entspricht, während das ref-Attribut und das docRef-Attribut in der Ref-Eigenschaft und der DocRef-Eigenschaft platziert werden.
Beispiel
Imports System
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 = "https://localhost/service1.asmx?wsdl"
' Set the URL for a XML Web service implementing the service
' description .
myContractReference.DocRef = "https://localhost/service1.asmx"
Dim myBinding As New SoapBinding()
myBinding.Binding = New XmlQualifiedName("q1:Service1Soap")
myBinding.Address = "https://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 'Main
End Class 'MyContractReference
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 = "https://localhost/service1.asmx?wsdl";
// Set the URL for an XML Web service implementing the service
// description.
myContractReference.DocRef = "https://localhost/service1.asmx";
SoapBinding myBinding = new SoapBinding();
myBinding.Binding = new XmlQualifiedName("q1:Service1Soap");
myBinding.Address = "https://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);
}
}
}
#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 = "https://localhost/service1.asmx?wsdl";
// Set the URL for an XML Web service implementing the service
// description.
myContractReference->DocRef = "https://localhost/service1.asmx";
SoapBinding^ myBinding = gcnew SoapBinding;
myBinding->Binding = gcnew XmlQualifiedName( "q1:Service1Soap" );
myBinding->Address = "https://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 );
}
}
import System.*;
import System.Xml.*;
import System.IO.*;
import System.Web.Services.Discovery.*;
public class MyContractReference
{
public static void main(String[] args)
{
try {
// Get a DiscoveryDocument.
DiscoveryDocument myDiscoveryDocument = new DiscoveryDocument();
// Get a ContractReference.
ContractReference myContractReference = new ContractReference();
// Set the URL to the referenced service description.
myContractReference.set_Ref("https://localhost/service1.asmx?wsdl");
// Set the URL for an XML Web service implementing the service
// description.
myContractReference.set_DocRef("https://localhost/service1.asmx");
SoapBinding myBinding = new SoapBinding();
myBinding.set_Binding(new XmlQualifiedName("q1:Service1Soap"));
myBinding.set_Address("https://localhost/service1.asmx");
// Add myContractReference to the list of references contained
// in the discovery document.
myDiscoveryDocument.get_References().Add(myContractReference);
// Add Binding to the references collection.
myDiscoveryDocument.get_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 (System.Exception e) {
Console.WriteLine("Error is " + e.get_Message());
}
} //main
} //MyContractReference
Vererbungshierarchie
System.Object
System.Web.Services.Discovery.DiscoveryReference
System.Web.Services.Discovery.ContractReference
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
ContractReference-Member
System.Web.Services.Discovery-Namespace
DiscoveryReference
ServiceDescription-Klasse
SchemaReference
DiscoveryDocumentReference
DiscoveryClientProtocol