SoapRpcMethodAttribute.Binding プロパティ
XML Web サービス メソッドが実装している操作のバインディングを取得または設定します。
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);
プロパティ値
XML Web サービス メソッドが実装している操作のバインディング。既定値は、"Soap" が追加された XML Web サービスの名前です。
解説
バインディングは、Web サービス記述言語 (WSDL: Web Services Description Language) によって定義されており、具体的な操作のセットを定義している点でインターフェイスと似ています。ASP.NET では、各 XML Web サービス メソッドは 1 つのバインディング内の 1 つの操作です。XML Web サービス メソッドは、XML Web サービスの既定のバインディングのメンバ、または XML Web サービスに適用される WebServiceBindingAttribute 内で指定されたバインディングのメンバになります。XML Web サービスは、複数の WebServiceBindingAttribute 属性が適用されている場合には、複数のバインディングを実装できます。
WebServiceBindingAttribute 属性を XML Web サービスに適用すると、 SoapDocumentMethodAttribute または SoapRpcMethodAttribute を個別の XML Web サービス メソッドに適用し、特定の XML Web サービス メソッドによって実装されるバインディング操作を指定できます。 SoapDocumentMethodAttribute または SoapRpcMethodAttribute の Binding プロパティを設定して、XML Web サービス メソッドが実装する操作のバインディングを指定します。XML Web サービス メソッドに適用できるのは、1 つの SoapDocumentMethodAttribute または SoapRpcMethodAttribute だけです。したがって、XML Web サービス メソッドが実装できるのは、1 つのバインディングに対して 1 つの操作だけです。
使用例
[Visual Basic, C#] XML Web サービス内に複数のバインディングを実装する方法を次のコード例に示します。
<%@ 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:="https://www.contoso.com/MyBinding"), _
WebServiceBinding(Name:="RemoteBinding",Namespace:="https://www.contoso.com/MyBinding",Location:="https://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
[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 not a part of the default namespace.
[ WebServiceBinding(Name="LocalBindingNonDefaultNamespace", Namespace="https://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="https://www.contoso.com/MyBinding",Location="https://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";
}
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
SoapRpcMethodAttribute クラス | SoapRpcMethodAttribute メンバ | System.Web.Services.Protocols 名前空間 | WebServiceBindingAttribute