Sdílet prostřednictvím


SoapRpcMethodAttribute.Binding Vlastnost

Definice

Získá nebo nastaví vazbu, pro kterou metoda webové služby XML implementuje operaci.

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

Hodnota vlastnosti

String

Vazba metody webové služby XML implementuje operaci. Výchozí hodnota je název webové služby XML s připojeným protokolem Soap.

Příklady

Následující příklad kódu ukazuje, jak implementovat více vazeb ve webové službě 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

Poznámky

Vazba definovaná jazykem WSDL (Web Services Description Language) se podobá rozhraní, ve které definuje konkrétní sadu operací. Vzhledem k ASP.NET je každá metoda webové služby XML operací v rámci vazby. Metody webové služby XML jsou členy výchozí vazby webové služby XML nebo vazby zadané v WebServiceBindingAttribute rámci webové služby XML. Webová služba XML může implementovat více vazeb, pokud se u webové služby XML použije více WebServiceBindingAttribute atributů.

Jakmile se na webovou službu XML použije jeden nebo více WebServiceBindingAttribute atributů, SoapDocumentMethodAttribute můžete SoapRpcMethodAttribute je použít u jednotlivých metod webové služby XML k označení operace vazby implementované konkrétní metodou webové služby XML. Binding Nastavte vlastnost SoapDocumentMethodAttribute nebo SoapRpcMethodAttribute určit vazbu metody webové služby XML implementuje operaci. Pro metodu webové služby XML lze použít pouze jednu SoapDocumentMethodAttribute nebo SoapRpcMethodAttribute lze použít. Proto může metoda webové služby XML implementovat pouze operaci pro jednu vazbu.

Platí pro

Viz také