Freigeben über


ServiceDescription-Klasse

Bietet eine Möglichkeit zum Erstellen und Formatieren einer gültigen WSDL-Dokumentdatei (Web Services Description Language-Dokumentdatei) mit den entsprechenden Namespaces, Elementen und Attributen zur Beschreibung eines XML-Webdiensts. Diese Klasse kann nicht geerbt werden.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public NotInheritable Class ServiceDescription
    Inherits NamedItem
'Usage
Dim instance As ServiceDescription
public sealed class ServiceDescription : NamedItem
public ref class ServiceDescription sealed : public NamedItem
public final class ServiceDescription extends NamedItem
public final class ServiceDescription extends NamedItem

Hinweise

Instanzen dieser Klasse können entweder mit dem new-Schlüsselwort oder mit der statischen Read-Methode erstellt werden, die eine WSDL-Datei analysiert und ihre Werte den entsprechenden Membern der Klasse zuordnet.

WSDL ist eine auf XML basierende Sprache zum Beschreiben von XML-Webdiensten. Die ServiceDescription-Klasse entspricht dem Stammelement (definitions) einer WSDL-Datei. Weitere Informationen zu WSDL finden Sie in der Spezifikation unter http://www.w3.org/TR/wsdl/.

Beispiel

Im folgenden Beispiel wird veranschaulicht, wie eine Instanz der ServiceDescription-Klasse erstellt wird.

' Obtain the ServiceDescription of existing Wsdl.
Dim myDescription As ServiceDescription = ServiceDescription.Read("MyWsdl_VB.wsdl")
' Remove the Binding from the Binding Collection of ServiceDescription.
Dim myBindingCollection As BindingCollection = myDescription.Bindings
myBindingCollection.Remove(myBindingCollection(0))

' Form a new Binding.
Dim myBinding As New Binding()
myBinding.Name = "Service1Soap"
Dim myXmlQualifiedName As New XmlQualifiedName("s0:Service1Soap")
myBinding.Type = myXmlQualifiedName

Dim mySoapBinding As New SoapBinding()
mySoapBinding.Transport = "https://schemas.xmlsoap.org/soap/http"
mySoapBinding.Style = SoapBindingStyle.Document

Dim addOperationBinding As OperationBinding = CreateOperationBinding("Add", _
                                             myDescription.TargetNamespace)
myBinding.Operations.Add(addOperationBinding)
myBinding.Extensions.Add(mySoapBinding)

' Add the Binding to the ServiceDescription.
myDescription.Bindings.Add(myBinding)
myDescription.Write("MyOutWsdl.wsdl")
// Obtain the ServiceDescription of existing Wsdl.
ServiceDescription myDescription = ServiceDescription.Read("MyWsdl_CS.wsdl");
// Remove the Binding from the Binding Collection of ServiceDescription.
BindingCollection myBindingCollection = myDescription.Bindings;
myBindingCollection.Remove(myBindingCollection[0]);

// Form a new Binding.
Binding myBinding = new Binding();
myBinding.Name = "Service1Soap";
XmlQualifiedName myXmlQualifiedName = 
                     new XmlQualifiedName("s0:Service1Soap");
myBinding.Type = myXmlQualifiedName;

SoapBinding mySoapBinding = new SoapBinding();
mySoapBinding.Transport = "https://schemas.xmlsoap.org/soap/http";
mySoapBinding.Style = SoapBindingStyle.Document;

OperationBinding addOperationBinding = 
       CreateOperationBinding("Add",myDescription.TargetNamespace);
myBinding.Operations.Add(addOperationBinding);
myBinding.Extensions.Add(mySoapBinding);

// Add the Binding to the ServiceDescription.
myDescription.Bindings.Add(myBinding);
myDescription.Write("MyOutWsdl.wsdl");
// Obtain the ServiceDescription of existing Wsdl.
ServiceDescription^ myDescription = ServiceDescription::Read( "MyWsdl_CS.wsdl" );

// Remove the Binding from the Binding Collection of ServiceDescription.
BindingCollection^ myBindingCollection = myDescription->Bindings;
myBindingCollection->Remove( myBindingCollection[ 0 ] );

// Form a new Binding.
Binding^ myBinding = gcnew Binding;
myBinding->Name = "Service1Soap";
XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:Service1Soap" );
myBinding->Type = myXmlQualifiedName;
SoapBinding^ mySoapBinding = gcnew SoapBinding;
mySoapBinding->Transport = "https://schemas.xmlsoap.org/soap/http";
mySoapBinding->Style = SoapBindingStyle::Document;
OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myDescription->TargetNamespace );
myBinding->Operations->Add( addOperationBinding );
myBinding->Extensions->Add( mySoapBinding );

// Add the Binding to the ServiceDescription.
myDescription->Bindings->Add( myBinding );
myDescription->Write( "MyOutWsdl.wsdl" );
// Obtain the ServiceDescription of existing Wsdl.
ServiceDescription myDescription = ServiceDescription.
    Read("MyWsdl_JSL.wsdl");
// Remove the Binding from the Binding Collection of 
// ServiceDescription.
BindingCollection myBindingCollection = myDescription.
    get_Bindings();
myBindingCollection.Remove(myBindingCollection.get_Item(0));
// Form a new Binding.
Binding myBinding = new Binding();
myBinding.set_Name("Service1Soap");
XmlQualifiedName myXmlQualifiedName = new 
    XmlQualifiedName("s0:Service1Soap");
myBinding.set_Type(myXmlQualifiedName);

SoapBinding mySoapBinding = new SoapBinding();
mySoapBinding.set_Transport("https://schemas.xmlsoap.org/soap/http");
mySoapBinding.set_Style(SoapBindingStyle.Document);

OperationBinding addOperationBinding = CreateOperationBinding("Add",
    myDescription.get_TargetNamespace());
myBinding.get_Operations().Add(addOperationBinding);
myBinding.get_Extensions().Add(mySoapBinding);
// Add the Binding to the ServiceDescription.
myDescription.get_Bindings().Add(myBinding);
myDescription.Write("MyOutWsdl.wsdl");

Vererbungshierarchie

System.Object
   System.Web.Services.Description.DocumentableItem
     System.Web.Services.Description.NamedItem
      System.Web.Services.Description.ServiceDescription

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

ServiceDescription-Member
System.Web.Services.Description-Namespace