WebServiceBindingAttribute Třída

Definice

Deklaruje vazbu, která definuje jednu nebo více metod webové služby XML. Tuto třídu nelze zdědit.

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 | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=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
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)>]
type WebServiceBindingAttribute = class
    inherit Attribute
Public NotInheritable Class WebServiceBindingAttribute
Inherits Attribute
Dědičnost
WebServiceBindingAttribute
Atributy

Příklady

Následující webová služba XML implementuje operace ze čtyř vazeb. Webová služba XML konkrétně deklaruje tři vazby, pro které implementuje operace, použitím tří WebServiceBindingAttribute atributů na webovou službu XML.

Chcete-li určit, pro kterou vazbu metoda webové služby XML implementuje operaci, SoapDocumentMethodAttribute použije se u každé z metod webové služby XML s výjimkou DefaultBindingMethod. Když vazbu DefaultBindingMethodnezadáte, implementuje operaci pro výchozí vazbu pro webovou službu 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

Poznámky

Vazba definovaná jazykem WSDL (Web Services Description Language) se podobá rozhraní, v tom, že definuje konkrétní sadu operací. Každá metoda webové služby XML je operace v rámci konkrétní vazby. Metody webové služby XML jsou členy výchozí vazby webové služby XML nebo vazby zadané v rámci WebServiceBindingAttribute třídy implementující webovou službu XML. Webová služba XML může implementovat více vazeb použitím více WebServiceBindingAttribute atributů na webovou službu XML.

Jakmile se u webové služby XML použije jeden nebo více WebServiceAttribute atributů, lze SoapDocumentMethodAttribute SoapRpcMethodAttribute jej použít u jednotlivých metod webové služby XML, které označují operaci vazby implementovanou konkrétní metodou webové služby XML. Binding Nastavte vlastnost SoapDocumentMethodAttribute nebo SoapRpcMethodAttribute určit vazbu metody webové služby XML implementuje operaci pro.

Konstruktory

WebServiceBindingAttribute()

Inicializuje novou instanci WebServiceBindingAttribute třídy.

WebServiceBindingAttribute(String)

Inicializuje novou instanci WebServiceBindingAttribute třídy nastavení název vazby xml webová služba metoda implementuje.

WebServiceBindingAttribute(String, String)

Inicializuje novou instanci WebServiceBindingAttribute třídy.

WebServiceBindingAttribute(String, String, String)

Inicializuje novou instanci WebServiceBindingAttribute třídy.

Vlastnosti

ConformsTo

Získá nebo nastaví specifikaci interoperability webových služeb (WSI), na kterou se vazby deklarace identity odpovídají.

EmitConformanceClaims

Získá nebo nastaví hodnotu, která označuje, zda vazba generuje deklarace shody.

Location

Získá nebo nastaví umístění, kde je vazba definována.

Name

Získá nebo nastaví název vazby.

Namespace

Získá nebo nastaví obor názvů přidružený k vazbě.

TypeId

Při implementaci v odvozené třídě získá jedinečný identifikátor pro tento Attribute.

(Zděděno od Attribute)

Metody

Equals(Object)

Vrací hodnotu, která určuje, zda je tato instance rovna zadanému objektu.

(Zděděno od Attribute)
GetHashCode()

Vrátí hodnotu hash pro tuto instanci.

(Zděděno od Attribute)
GetType()

Type Získá aktuální instanci.

(Zděděno od Object)
IsDefaultAttribute()

Při přepsání v odvozené třídě určuje, zda hodnota této instance je výchozí hodnotou odvozené třídy.

(Zděděno od Attribute)
Match(Object)

Při přepsání v odvozené třídě vrátí hodnotu, která označuje, zda se tato instance rovná zadanému objektu.

(Zděděno od Attribute)
MemberwiseClone()

Vytvoří použádnou kopii aktuálního souboru Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Explicitní implementace rozhraní

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

Mapuje sadu názvů na odpovídající sadu identifikátorů pro rozesílání.

(Zděděno od Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Načte informace o typu objektu, který lze použít k získání informací o typu rozhraní.

(Zděděno od Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Získá počet rozhraní typu informací, které objekt poskytuje (0 nebo 1).

(Zděděno od Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Poskytuje přístup k vlastnostem a metodám vystaveným objektem.

(Zděděno od Attribute)

Platí pro

Viz také