This documentation is archived and is not being maintained.

SoapDocumentMethodAttribute.Binding Property

Gets or sets the binding an XML Web service method is implementing an operation for.

[Visual Basic]
Public Property Binding As String
[C#]
public string Binding {get; set;}
[C++]
public: __property String* get_Binding();
public: __property void set_Binding(String*);
[JScript]
public function get Binding() : String;
public function set Binding(String);

Property Value

The binding an XML Web service method is implementing an operation for. The default is the name of the XML Web service with "Soap" appended.

Remarks

A binding, as defined by Web Services Description Language (WSDL), is similar to an interface in that it defines a concrete set of operations. With respect to XML Web services created using ASP.NET, each XML Web service method is an operation within a binding. XML Web service methods are members of either the default binding for an XML Web service or a binding specified within a WebServiceBindingAttribute applied to an XML Web service. An XML Web service can implement multiple bindings when multiple WebServiceBindingAttribute attributes are applied to an XML Web service.

Once one or more WebServiceBindingAttribute attributes are applied to an XML Web service, a SoapDocumentMethodAttribute or SoapRpcMethodAttribute can be applied to individual XML Web service methods to indicate the binding operation implemented by a particular XML Web service method. Set the Binding property of SoapDocumentMethodAttribute or SoapRpcMethodAttribute to specify the binding an XML Web service method is implementing an operation for. Only one SoapDocumentMethodAttribute or SoapRpcMethodAttribute can be applied to an XML Web service method. Therefore, an XML Web service method can only implement an operation for one binding.

For more information on the WSDL specification, see the W3C Web site (http://www.w3.org/TR/wsdl).

Example

[Visual Basic] 
<%@ 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  

      < 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

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

[C#] 
<%@ 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="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  {

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

     [ SoapDocumentMethodAttribute(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.";
      }
 
 }   

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

SoapDocumentMethodAttribute Class | SoapDocumentMethodAttribute Members | System.Web.Services.Protocols Namespace | WebServiceBindingAttribute

Show: