Partilhar via


SoapRpcMethodAttribute.Binding Propriedade

Definição

Obtém ou define a associação para a qual um método de serviço Web XML implementa uma operação.

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

Valor da propriedade

A associação de um método de serviço Web XML implementa uma operação para. O padrão é o nome do serviço Web XML com "Soap" acrescentado.

Exemplos

O exemplo de código a seguir demonstra como implementar várias associações em um serviço Web XML.

<%@ 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

Comentários

Uma associação, conforme definido pela Linguagem de Descrição dos Serviços Web (WSDL), é semelhante a uma interface na qual define um conjunto concreto de operações. Com relação a ASP.NET, cada método de serviço Web XML é uma operação dentro de uma associação. Os métodos de serviço Web XML são membros da associação padrão para um serviço Web XML ou uma associação especificada em um WebServiceBindingAttribute serviço Web XML aplicado. Um serviço Web XML poderá implementar várias associações se vários WebServiceBindingAttribute atributos forem aplicados a um serviço Web XML.

Uma vez que um ou mais WebServiceBindingAttribute atributos são aplicados a um serviço Web XML, um SoapDocumentMethodAttribute ou SoapRpcMethodAttribute pode ser aplicado a métodos de serviço Web XML individuais para indicar a operação de associação implementada por um método de serviço Web XML específico. Defina a Binding propriedade de SoapDocumentMethodAttribute ou SoapRpcMethodAttribute para especificar a associação para a qual um método de serviço Web XML implementa uma operação. Apenas um SoapDocumentMethodAttribute ou SoapRpcMethodAttribute pode ser aplicado a um método de serviço Web XML. Portanto, um método de serviço Web XML só pode implementar uma operação para uma associação.

Aplica-se a

Confira também