Bewerken

Delen via


WebServiceBindingAttribute Constructors

Definition

Initializes a new instance of the WebServiceBindingAttribute class.

Overloads

WebServiceBindingAttribute()

Initializes a new instance of the WebServiceBindingAttribute class.

WebServiceBindingAttribute(String)

Initializes a new instance of the WebServiceBindingAttribute class setting the name of the binding the XML Web service method is implementing.

WebServiceBindingAttribute(String, String)

Initializes a new instance of the WebServiceBindingAttribute class.

WebServiceBindingAttribute(String, String, String)

Initializes a new instance of the WebServiceBindingAttribute class.

WebServiceBindingAttribute()

Initializes a new instance of the WebServiceBindingAttribute class.

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

Applies to

WebServiceBindingAttribute(String)

Initializes a new instance of the WebServiceBindingAttribute class setting the name of the binding the XML Web service method is implementing.

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)

Parameters

name
String

The name of the binding an XML Web service method is implementing an operation for. Sets the Name property.

Examples

The following example specifies a binding named LocalBinding that is defined in the BindingSample XML Web service.

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

Remarks

This constructor is used to specify a name for a binding defined in the XML Web service it is applied to and is a member of the default namespace.

See also

Applies to

WebServiceBindingAttribute(String, String)

Initializes a new instance of the WebServiceBindingAttribute class.

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)

Parameters

name
String

The name of the binding an XML Web service method is implementing an operation for. Sets the Name property.

ns
String

The namespace associated with the binding. Sets the Namespace property.

Examples

The following example specifies a binding named LocalBindingNonDefaultNamespace that is a member of the http://www.contoso.com/MyBinding namespace and defined in the BindingSample XML Web service.

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

Remarks

This constructor is used to specify a name for a binding defined in the XML Web service it is applied to that and is a member of the supplied namespace.

See also

Applies to

WebServiceBindingAttribute(String, String, String)

Initializes a new instance of the WebServiceBindingAttribute class.

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)

Parameters

name
String

The name of the binding an XML Web service method is implementing an operation for. Sets the Name property.

ns
String

The namespace associated with the binding. Sets the Namespace property.

location
String

The location where the binding is defined.

Examples

The following example specifies a binding named RemoteBinding that is a member of the http://www.contoso.com/MyBinding namespace and defined at 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>

Remarks

This constructor is used to specify a name for a binding not defined in the XML Web service it is applied to that and is a member of the supplied namespace.

See also

Applies to