WebServiceBindingAttribute クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface, AllowMultiple:=True)> _ Public NotInheritable Class WebServiceBindingAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true)] public sealed class WebServiceBindingAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Interface, AllowMultiple=true)] public ref class WebServiceBindingAttribute sealed : public Attribute

WSDL (Web Services Description Language) によって定義されているバインディングは、具体的な操作のセットを定義している点でインターフェイスと似ています。各 XML Web サービス メソッドは、特定のバインディング内の操作です。XML Web サービス メソッドは、XML Web サービスの既定のバインディングのメンバ、または XML Web サービスを実装しているクラスに適用された WebServiceBindingAttribute の中で指定されたバインディングのメンバです。複数の WebServiceBindingAttribute 属性を 1 つの XML Web サービスに適用することにより、1 つの XML Web サービスで複数のバインディングを実装できます。
WebServiceAttribute 属性を XML Web サービスに適用すると、SoapDocumentMethodAttribute または SoapRpcMethodAttribute を個別の XML Web サービス メソッドに適用し、特定の XML Web サービス メソッドによって実装されるバインディング操作を指定できます。SoapDocumentMethodAttribute または SoapRpcMethodAttribute の Binding プロパティを設定して、XML Web サービス メソッドが操作を実装する対象となるバインディングを指定します。

4 つのバインディングで操作を実装する XML Web サービスを次に示します。特に、XML Web サービスは、3 つの WebServiceBindingAttribute 属性を XML Web サービスに適用して、操作を実装する対象となる 3 つのバインディングを宣言します。
XML Web サービス メソッドが操作を実装する対象であるバインディングを指定するために、DefaultBindingMethod を除く各 XML Web サービス メソッドに SoapDocumentMethodAttribute が適用されます。DefaultBindingMethod のバインディングを指定しないことによって、XML Web サービスの既定のバインディングに操作を実装しています。
<%@ WebService Language="VB" class="BindingSample" %> Imports System Imports System.Web.Services Imports System.Web.Services.Protocols ' Binding is defined in this XML Web service and uses the default namespace. ' Binding is defined in this XML Web service, but it is not a part of the default ' namespace. ' Binding is defined on a remote server, but this XML Web service implements at ' least one operation in that binding. <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 <SoapDocumentMethod(Binding := "LocalBindingNonDefaultNamespace"), WebMethod()> _ Public Function LocalBindingNonDefaultNamespaceMethod() As String Return "Member o1f binding defined in this XML Web service, but a part of a different namespace" End Function <SoapDocumentMethod(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
<%@ 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"; } [ SoapDocumentMethod(Binding="LocalBindingNonDefaultNamespace")] [ WebMethod() ] public string LocalBindingNonDefaultNamespaceMethod() { return "Member of binding defined in this XML Web service, but a part of a different namespace"; } [ SoapDocumentMethod(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"; } }

System.Attribute
System.Web.Services.WebServiceBindingAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- WebServiceBindingAttribute クラスのページへのリンク