Share via


SoapRpcMethodAttribute.Binding プロパティ

定義

XML Web サービス メソッドが実装している操作のバインディングを取得または設定します。

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

プロパティ値

XML Web サービス メソッドが実装している操作のバインディング。 既定値は、"Soap" が追加された XML Web サービスの名前です。

次のコード例は、XML Web サービス内に複数のバインドを実装する方法を示しています。

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

注釈

Web サービス記述言語 (WSDL) で定義されているバインディングは、具体的な一連の操作を定義するという点でインターフェイスに似ています。 ASP.NET に関して、各 XML Web サービス メソッドはバインディング内の操作です。 XML Web サービス メソッドは、XML Web サービスの既定のバインドのメンバー、または XML Web サービスに適用される 内で WebServiceBindingAttribute 指定されたバインディングです。 XML Web サービスに複数の属性が適用されている場合、XML Web サービスは複数 WebServiceBindingAttribute のバインディングを実装できます。

1 つ以上 WebServiceBindingAttribute の属性が XML Web サービスに適用されると、 SoapDocumentMethodAttribute または SoapRpcMethodAttribute を個々の XML Web サービス メソッドに適用して、特定の XML Web サービス メソッドによって実装されるバインド操作を示すことができます。 または SoapRpcMethodAttributeSoapDocumentMethodAttribute プロパティをBinding設定して、XML Web サービス メソッドが操作を実装するバインドを指定します。 XML Web サービス メソッドに適用できる または SoapRpcMethodAttribute は 1 SoapDocumentMethodAttribute つだけです。 したがって、XML Web サービス メソッドは、1 つのバインドに対してのみ操作を実装できます。

適用対象

こちらもご覧ください