Freigeben über


WebServiceBindingAttribute-Klasse

Deklariert eine Bindung, die eine oder mehrere XML-Webdienstmethoden definiert. Diese Klasse kann nicht geerbt werden.

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

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface, AllowMultiple:=True)> _
Public NotInheritable Class WebServiceBindingAttribute
    Inherits Attribute
'Usage
Dim instance As WebServiceBindingAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true)] 
public sealed class WebServiceBindingAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Interface, AllowMultiple=true)] 
public ref class WebServiceBindingAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true) */ 
public final class WebServiceBindingAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true) 
public final class WebServiceBindingAttribute extends Attribute

Hinweise

Gemäß WSDL-Definition (Web Services Description Language) ähnelt eine Bindung insofern einer Schnittstelle, als sie einen konkreten Satz von Operationen definiert. Jede XML-Webdienstmethode ist eine Operation innerhalb einer bestimmten Bindung. XML-Webdienstmethoden sind entweder Member der Standardbindung für einen XML-Webdienst oder einer Bindung, die innerhalb eines WebServiceBindingAttribute angegeben wird, das auf eine Klasse angewendet wird, die einen XML-Webdienst implementiert. Ein XML-Webdienst kann mehrere Bindungen implementieren, indem mehrere WebServiceBindingAttribute-Attribute auf einen XML-Webdienst angewendet werden.

Wenn einem XML-Webdienst ein oder mehrere WebServiceAttribute-Attribute zugewiesen wurden, können einzelnen XML-Webdienstmethoden ein SoapDocumentMethodAttribute oder ein SoapRpcMethodAttribute zugewiesen werden, um den durch eine bestimmte XML-Webdienstmethode implementierten Bindungsvorgang anzugeben. Legen Sie die Binding-Eigenschaft von SoapDocumentMethodAttribute oder SoapRpcMethodAttribute fest, um die Bindung anzugeben, für die eine XML-Webdienstmethode eine Operation implementiert.

Beispiel

Der folgende XML-Webdienst implementiert Operationen von vier Bindungen. Der XML-Webdienst deklariert drei Bindungen, für die er Operationen implementiert, indem drei WebServiceBindingAttribute-Attribute auf den XML-Webdienst angewendet werden.

Um anzugeben, für welche Bindung eine XML-Webdienstmethode eine Operation implementiert, wird mit Ausnahme von DefaultBindingMethod ein SoapDocumentMethodAttribute auf jede der XML-Webdienstmethoden angewendet. Dadurch, dass für DefaultBindingMethod keine Bindung angegeben wird, wird eine Operation für die Standardbindung für den XML-Webdienst implementiert.

<%@ WebService Language="VB" class="BindingSample" %>
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols

' Binding is defined in this XML Web service and uses the default namespace.
' Binding is defined in this XML Web service, but it is not a part of the default
' namespace.
' Binding is defined on a remote server, but this XML Web service implements at
' least one operation in that binding.
<WebServiceBinding(Name := "LocalBinding"), _ 
 WebServiceBinding(Name := "LocalBindingNonDefaultNamespace", _ 
                   Namespace := "https://www.contoso.com/MyBinding"), _     
 WebServiceBinding(Name := "RemoteBinding", _ 
                   Namespace := "https://www.contoso.com/MyBinding", _
                   Location := "https://www.contoso.com/MySevice.asmx?wsdl")> _
Public Class BindingSample
    
    <SoapDocumentMethod(Binding := "LocalBinding"), WebMethod()> _
    Public Function LocalBindingMethod() As String
        
        Return "Member of binding defined in this XML Web service and member of the default namespace"
    End Function
    
    <SoapDocumentMethod(Binding := "LocalBindingNonDefaultNamespace"), WebMethod()> _
    Public Function LocalBindingNonDefaultNamespaceMethod() As String
    
        Return "Member o1f binding defined in this XML Web service, but a part of a different namespace"
    End Function    
    
    <SoapDocumentMethod(Binding := "RemoteBinding"), WebMethod()> _
    Public Function RemoteBindingMethod() As String
    
        Return "Member of a binding defined on another server"
    End Function    
    
    <WebMethod()> _
    Public Function DefaultBindingMethod() As String
    
        Return "Member of the default binding"
    End Function
End Class
<%@ WebService Language="C#" class="BindingSample" %>
 using System;
 using System.Web.Services;
 using System.Web.Services.Protocols;

 // Binding is defined in this XML Web service and uses the default namespace.
 [ WebServiceBinding(Name="LocalBinding")]

 // Binding is defined in this XML Web service, but it is not a part of the default namespace.
 [ WebServiceBinding(Name="LocalBindingNonDefaultNamespace", 
             Namespace="https://www.contoso.com/MyBinding" )]

 // Binding is defined on a remote server, but this XML Web service implements at least one operation in that binding.
 [ WebServiceBinding(Name="RemoteBinding", 
          Namespace="https://www.contoso.com/MyBinding",
          Location="https://www.contoso.com/MySevice.asmx?wsdl")]
 public class BindingSample  {

      [ SoapDocumentMethod(Binding="LocalBinding")]
      [ WebMethod() ]
      public string LocalBindingMethod() {
               return "Member of binding defined in this XML Web service and member of the default namespace";
      }
      [ SoapDocumentMethod(Binding="LocalBindingNonDefaultNamespace")] 
      [ WebMethod() ]
      public string LocalBindingNonDefaultNamespaceMethod() {
              return "Member of binding defined in this XML Web service, but a part of a different namespace";
      }

     [ SoapDocumentMethod(Binding="RemoteBinding")] 
     [ WebMethod() ]
      public string RemoteBindingMethod() {
              return "Member of a binding defined on another server";
      }

      [ WebMethod() ]
      public string DefaultBindingMethod() {
              return "Member of the default binding";
      }
 
 }

Vererbungshierarchie

System.Object
   System.Attribute
    System.Web.Services.WebServiceBindingAttribute

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 CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, 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

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

WebServiceBindingAttribute-Member
System.Web.Services-Namespace
SoapDocumentMethodAttribute
SoapRpcMethodAttribute