WebServiceBindingAttribute Klasa

Definicja

Deklaruje powiązanie definiujące co najmniej jedną metodę usługi sieci Web XML. Klasa ta nie może być dziedziczona.

public ref class WebServiceBindingAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true)]
public sealed class WebServiceBindingAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true)]
public sealed class WebServiceBindingAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true)>]
type WebServiceBindingAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true)>]
type WebServiceBindingAttribute = class
    inherit Attribute
Public NotInheritable Class WebServiceBindingAttribute
Inherits Attribute
Dziedziczenie
WebServiceBindingAttribute
Atrybuty

Przykłady

Poniższa usługa sieci Web XML implementuje operacje z czterech powiązań. W szczególności usługa sieci Web XML deklaruje trzy powiązania, dla których implementuje operacje, stosując trzy WebServiceBindingAttribute atrybuty do usługi sieci Web XML.

Aby określić, które powiązanie metody usługi sieci Web XML implementuje operację, SoapDocumentMethodAttribute element jest stosowany do każdej metody usługi sieci Web XML, z wyjątkiem DefaultBindingMethod. Nie określając powiązania dla DefaultBindingMethodprogramu , implementuje operację na domyślnym powiązaniu dla usługi sieci Web XML.

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

Uwagi

Powiązanie zdefiniowane przez język opisu usług sieci Web (WSDL) jest podobne do interfejsu, w ramach którego definiuje konkretny zestaw operacji. Każda metoda usługi sieci Web XML jest operacją w określonym powiązaniu. Metody usługi sieci Web XML są elementami członkowskimi domyślnego powiązania dla usługi sieci Web XML lub powiązania określonego WebServiceBindingAttribute w ramach klasy implementowania usługi sieci Web XML. Usługa sieci Web XML może implementować wiele powiązań, stosując wiele WebServiceBindingAttribute atrybutów do usługi sieci Web XML.

Po zastosowaniu co najmniej jednego WebServiceAttribute atrybutu do usługi SoapDocumentMethodAttribute sieci Web XML można zastosować element lub SoapRpcMethodAttribute do poszczególnych metod usługi sieci Web XML, aby wskazać operację powiązania zaimplementowaną przez określoną metodę usługi sieci Web XML. Binding Ustaw właściwość SoapDocumentMethodAttribute lub SoapRpcMethodAttribute określ powiązanie metody usługi sieci Web XML implementuje operację .

Konstruktory

WebServiceBindingAttribute()

Inicjuje nowe wystąpienie klasy WebServiceBindingAttribute.

WebServiceBindingAttribute(String)

Inicjuje WebServiceBindingAttribute nowe wystąpienie klasy, ustawiając nazwę powiązania, które implementuje metoda usługi sieci Web XML.

WebServiceBindingAttribute(String, String)

Inicjuje nowe wystąpienie klasy WebServiceBindingAttribute.

WebServiceBindingAttribute(String, String, String)

Inicjuje nowe wystąpienie klasy WebServiceBindingAttribute.

Właściwości

ConformsTo

Pobiera lub ustawia specyfikację współdziałania usług sieci Web (WSI), do której oświadczenia powiązania mają być zgodne.

EmitConformanceClaims

Pobiera lub ustawia wartość wskazującą, czy powiązanie emituje oświadczenia zgodności.

Location

Pobiera lub ustawia lokalizację, w której zdefiniowano powiązanie.

Name

Pobiera lub ustawia nazwę powiązania.

Namespace

Pobiera lub ustawia przestrzeń nazw skojarzona z powiązaniem.

TypeId

Po zaimplementowaniu w klasie pochodnej pobiera unikatowy identyfikator dla tego elementu Attribute.

(Odziedziczone po Attribute)

Metody

Equals(Object)

Zwraca wartość wskazującą, czy to wystąpienie jest równe podanemu obiektowi.

(Odziedziczone po Attribute)
GetHashCode()

Zwraca wartość skrótu dla tego wystąpienia.

(Odziedziczone po Attribute)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
IsDefaultAttribute()

W przypadku zastąpienia w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną klasy pochodnej.

(Odziedziczone po Attribute)
Match(Object)

W przypadku zastąpienia w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Pobiera informacje o typie obiektu, którego można użyć do pobrania informacji o typie interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy

Zobacz też