共用方式為


WebServiceBindingAttribute 建構函式

定義

初始化 WebServiceBindingAttribute 類別的新執行個體。

多載

WebServiceBindingAttribute()

初始化 WebServiceBindingAttribute 類別的新執行個體。

WebServiceBindingAttribute(String)

設定 XML Web Service 方法正在實作的繫結的名稱,初始化 WebServiceBindingAttribute 類別的新執行個體。

WebServiceBindingAttribute(String, String)

初始化 WebServiceBindingAttribute 類別的新執行個體。

WebServiceBindingAttribute(String, String, String)

初始化 WebServiceBindingAttribute 類別的新執行個體。

WebServiceBindingAttribute()

初始化 WebServiceBindingAttribute 類別的新執行個體。

public:
 WebServiceBindingAttribute();
public WebServiceBindingAttribute ();
Public Sub New ()

適用於

WebServiceBindingAttribute(String)

設定 XML Web Service 方法正在實作的繫結的名稱,初始化 WebServiceBindingAttribute 類別的新執行個體。

public:
 WebServiceBindingAttribute(System::String ^ name);
public WebServiceBindingAttribute (string name);
new System.Web.Services.WebServiceBindingAttribute : string -> System.Web.Services.WebServiceBindingAttribute
Public Sub New (name As String)

參數

name
String

XML Web Service 方法所要實作作業的繫結名稱。 設定 Name 屬性。

範例

下列範例會指定名為 LocalBinding 的系結,該系結定義于 XML Web 服務中 BindingSample

<%@ 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")]
 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";
      }

 }
<%@ WebService Language="VB" class="BindingSample" %>

Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols

' <Snippet1>
' Binding is defined in this XML Web service and uses the default namespace.
<WebServiceBinding(Name := "LocalBinding")> _
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 'LocalBindingMethod
    
End Class
   
' </Snippet1>

備註

此建構函式是用來指定套用至 XML Web 服務中之系結的名稱,而且是預設命名空間的成員。

另請參閱

適用於

WebServiceBindingAttribute(String, String)

初始化 WebServiceBindingAttribute 類別的新執行個體。

public:
 WebServiceBindingAttribute(System::String ^ name, System::String ^ ns);
public WebServiceBindingAttribute (string name, string ns);
new System.Web.Services.WebServiceBindingAttribute : string * string -> System.Web.Services.WebServiceBindingAttribute
Public Sub New (name As String, ns As String)

參數

name
String

XML Web Service 方法所要實作作業的繫結名稱。 設定 Name 屬性。

ns
String

與繫結相關聯的命名空間。 設定 Namespace 屬性。

範例

下列範例會指定名為 LocalBindingNonDefaultNamespace 的系結,該系結是命名空間的成員 http://www.contoso.com/MyBinding ,並在 XML Web 服務中 BindingSample 定義。

<%@ WebService Language="C#" class="BindingSample" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

// <Snippet1>
// 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")]
 public class BindingSample  {

      [ SoapDocumentMethod(Binding="LocalBindingNonDefaultNamespace")] 
      [ WebMethod() ]
      public string LocalBindingNonDefaultNamespaceMethod() {
              return "Member of binding defined in this XML Web service, but a part of a different namespace";
      }
 }
 
// </Snippet1>
<%@ WebService Language="VB" class="BindingSample" %>

Imports System
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

' <Snippet1>
' 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")> _
Public Class BindingSample   
    
    <SoapDocumentMethod(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
End Class
 
' </Snippet1>

備註

此建構函式是用來指定 XML Web 服務中定義之系結的名稱,而該系結會套用至該系結,而且是所提供命名空間的成員。

另請參閱

適用於

WebServiceBindingAttribute(String, String, String)

初始化 WebServiceBindingAttribute 類別的新執行個體。

public:
 WebServiceBindingAttribute(System::String ^ name, System::String ^ ns, System::String ^ location);
public WebServiceBindingAttribute (string name, string ns, string location);
new System.Web.Services.WebServiceBindingAttribute : string * string * string -> System.Web.Services.WebServiceBindingAttribute
Public Sub New (name As String, ns As String, location As String)

參數

name
String

XML Web Service 方法所要實作作業的繫結名稱。 設定 Name 屬性。

ns
String

與繫結相關聯的命名空間。 設定 Namespace 屬性。

location
String

定義繫結的位置。

範例

下列範例會指定名為 RemoteBinding 的系結,該系結是 命名空間的成員, http://www.contoso.com/MyBinding 且定義于 http://www.contoso.com/MyService.asmx?wsdl

<%@ WebService language="C#" class="BindingSample" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

// 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/MyService.asmx?wsdl" )]
 public class BindingSample  {

     [ SoapDocumentMethod(Binding="RemoteBinding")] 
     [ WebMethod() ]
      public string RemoteBindingMethod() {
              return "Member of a binding defined on another server";
      }
 }
<%@ WebService language="VB" class="BindingSample" %>

Imports System
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

' <Snippet1>
' 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/MyService.asmx?wsdl")> _
Public Class BindingSample    
    
    <SoapDocumentMethod(Binding := "RemoteBinding"), WebMethod()> _
    Public Function RemoteBindingMethod() As String
        
        Return "Member of a binding defined on another server"
    End Function
End Class
 
' </Snippet1>

備註

這個建構函式是用來指定未在 XML Web 服務中定義之系結的名稱,而且是所提供命名空間的成員。

另請參閱

適用於