Freigeben über


SoapRpcMethodAttribute.Binding Eigenschaft

Definition

Dient zum Abrufen oder Festlegen der Bindung, für die eine XML-Webdienstmethode einen Vorgang implementiert.

public:
 property System::String ^ Binding { System::String ^ get(); void set(System::String ^ value); };
public string Binding { get; set; }
member this.Binding : string with get, set
Public Property Binding As String

Eigenschaftswert

Die Bindung einer XML-Webdienstmethode implementiert einen Vorgang für. Der Standardwert ist der Name des XML-Webdiensts, an den "Soap" angefügt ist.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie mehrere Bindungen innerhalb eines XML-Webdiensts implementiert werden.

<%@ 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 not a part of the default namespace.
 [ WebServiceBinding(Name="LocalBindingNonDefaultNamespace", Namespace="http://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="http://www.contoso.com/MyBinding",Location="http://www.contoso.com/MySevice.asmx?wsdl")]
 public class BindingSample  {

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

     [ SoapRpcMethodAttribute(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";
      }
 
 }
<%@ WebService Language="VB" class="BindingSample" %>
 Imports System.Web.Services
 Imports System.Web.Services.Protocols

 ' Three bindings are defined
   < WebServiceBinding(Name:="LocalBinding"), _
   WebServiceBinding(Name:="LocalBindingNonDefaultNamespace",Namespace:="http://www.contoso.com/MyBinding"), _
   WebServiceBinding(Name:="RemoteBinding",Namespace:="http://www.contoso.com/MyBinding",Location:="http://www.contoso.com/MySevice.asmx?wsdl")> _
 Public class BindingSample  

      < SoapRpcMethod(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

          < SoapRpcMethodAttribute(Binding:="LocalBindingNonDefaultNamespace"), WebMethod > _
      Public Function LocalBindingNonDefaultNamespaceMethod() As String
        Return "Member of binding defined in this XML Web service, but a part of a different namespace"
      End Function
    
          < SoapRpcMethodAttribute(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

Hinweise

Eine Bindung, wie in der Beschreibungssprache für Webdienste (Web Services Description Language, WSDL) definiert, ähnelt einer Schnittstelle, in der sie einen konkreten Satz von Vorgängen definiert. Im Hinblick auf ASP.NET ist jede XML-Webdienstmethode ein Vorgang innerhalb einer Bindung. XML-Webdienstmethoden sind Member der Standardbindung für einen XML-Webdienst oder eine in einem WebServiceBindingAttribute XML-Webdienst angegebene Bindung. Ein XML-Webdienst kann mehrere Bindungen implementieren, wenn mehrere WebServiceBindingAttribute Attribute auf einen XML-Webdienst angewendet werden.

Sobald ein oder WebServiceBindingAttribute mehrere Attribute auf einen XML-Webdienst angewendet wurden, kann eine SoapDocumentMethodAttribute oder SoapRpcMethodAttribute mehrere Attribute auf einzelne XML-Webdienstmethoden angewendet werden, um den bindungsvorgang anzugeben, der von einer bestimmten XML-Webdienstmethode implementiert wird. Legen Sie die Binding Eigenschaft oder SoapRpcMethodAttributeSoapDocumentMethodAttribute die Bindung fest, für die eine XML-Webdienstmethode einen Vorgang implementiert. Nur eine oder SoapRpcMethodAttribute mehrere SoapDocumentMethodAttribute kann auf eine XML-Webdienstmethode angewendet werden. Daher kann eine XML-Webdienstmethode nur einen Vorgang für eine Bindung implementieren.

Gilt für:

Weitere Informationen