WebInvokeAttribute WebInvokeAttribute WebInvokeAttribute WebInvokeAttribute Class

Definición

Representa un atributo que indica que una operación de servicio es lógicamente una operación de invocación y que el modelo de programación WCF REST puede llamarla.Represents an attribute indicating that a service operation is logically an invoke operation and that it can be called by the WCF REST programming model.

public ref class WebInvokeAttribute sealed : Attribute, System::ServiceModel::Description::IOperationBehavior
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class WebInvokeAttribute : Attribute, System.ServiceModel.Description.IOperationBehavior
type WebInvokeAttribute = class
    inherit Attribute
    interface IOperationBehavior
Public NotInheritable Class WebInvokeAttribute
Inherits Attribute
Implements IOperationBehavior
Herencia
WebInvokeAttributeWebInvokeAttributeWebInvokeAttributeWebInvokeAttribute
Atributos
Implementaciones

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar el atributo WebInvokeAttribute.The following example shows how to use the WebInvokeAttribute attribute.

Nota

Dado que la propiedad Method no se especifica en el código siguiente, todas las operaciones del servicio se asignan al método POST de HTTP.Because the Method property is not specified in the following code, all service operations are mapped to the HTTP POST method.

[ServiceContract]
public interface ICalculator2
{
    [OperationContract]
    [WebInvoke]
    long Add(long x, long y);

    [OperationContract]
    [WebInvoke(UriTemplate = "Sub?x={x}&y={y}")]
    long Subtract(long x, long y);

    [OperationContract]
    [WebInvoke(UriTemplate = "Mult?x={x}&y={y}", BodyStyle = WebMessageBodyStyle.Bare)]
    long Multiply(long x, long y);

    [OperationContract]
    [WebInvoke(UriTemplate = "Div?x={x}&y={y}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat=WebMessageFormat.Xml)]
    long Divide(long x, long y);

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "Mod?x={x}&y={y}")]
    long Mod(long x, long y);
}
<ServiceContract()> _
Public Interface ICalculator2
    <OperationContract()> _
    <WebInvoke()> _
    Function Add(ByVal x As Long, ByVal y As Long) As Long

    <OperationContract()> _
    <WebInvoke(UriTemplate:="Sub?x={x}&y={y}")> _
    Function Subtract(ByVal x As Long, ByVal y As Long) As Long

    <OperationContract()> _
    <WebInvoke(UriTemplate:="Mult?x={x}&y={y}", BodyStyle:=WebMessageBodyStyle.Bare)> _
    Function Multiply(ByVal x As Long, ByVal y As Long) As Long

    <OperationContract()> _
    <WebInvoke(UriTemplate:="Div?x={x}&y={y}", BodyStyle:=WebMessageBodyStyle.Bare, RequestFormat:=WebMessageFormat.Xml, ResponseFormat:=WebMessageFormat.Xml)> _
    Function Divide(ByVal x As Long, ByVal y As Long) As Long

    <OperationContract()> _
   <WebInvoke(Method:="POST", UriTemplate:="Mod?x={x}&y={y}")> _
   Function Modulo(ByVal x As Long, ByVal y As Long) As Long
End Interface

Comentarios

El atributo WebInvokeAttribute se aplica a una operación de servicio además del OperationContractAttribute y asocia la operación a una UriTemplate así como a un verbo de transporte subyacente que representa una invocación (por ejemplo, HTTP POST, PUT o DELETE).The WebInvokeAttribute attribute is applied to a service operation in addition to the OperationContractAttribute and associates the operation with a UriTemplate as well as an underlying transport verb that represents an invocation (for example, HTTP POST, PUT, or DELETE). El WebInvokeAttribute atributo es un pasivo comportamiento de la operación (el IOperationBehavior métodos no hacen nada) que agrega metadatos a la descripción de la operación.The WebInvokeAttribute attribute is a passive operation behavior (the IOperationBehavior methods do nothing) that adds metadata to the operation description. Aplicar el atributo WebInvokeAttribute a una operación de servicio no tiene ningún efecto, a menos que se agregue un comportamiento que busque estos metadatos en la descripción de la operación (como WebHttpBehavior) a la colección de comportamientos del servicio.Applying the WebInvokeAttribute attribute to a service operation has no effect unless a behavior that looks for this metadata in the operation description (such as WebHttpBehavior) is added to the service's behavior collection. WebInvokeAttribute determina a qué método HTTP responde una operación del servicio.The WebInvokeAttribute determines what HTTP method that a service operation responds to. De forma predeterminada, todos los métodos que tienen WebInvokeAttribute aplicado responden a las solicitudes POST.By default, all methods that have the WebInvokeAttribute applied respond to POST requests. La propiedad Method permite especificar un método HTTP diferente.The Method property allows you to specify a different HTTP method. Si desea que una operación del servicio responda a GET, utilice el WebGetAttribute en su lugar.If you want a service operation to respond to GET, use the WebGetAttribute instead.

Constructores

WebInvokeAttribute() WebInvokeAttribute() WebInvokeAttribute() WebInvokeAttribute()

Inicializa una nueva instancia de la clase WebInvokeAttribute.Initializes a new instance of the WebInvokeAttribute class.

Propiedades

BodyStyle BodyStyle BodyStyle BodyStyle

Obtiene y establece el estilo del cuerpo de los mensajes que se envían a y desde la operación del servicio.Gets and sets the body style of the messages that are sent to and from the service operation.

IsBodyStyleSetExplicitly IsBodyStyleSetExplicitly IsBodyStyleSetExplicitly IsBodyStyleSetExplicitly

Obtiene la propiedad IsBodyStyleSetExplicitly.Gets the IsBodyStyleSetExplicitly property.

IsRequestFormatSetExplicitly IsRequestFormatSetExplicitly IsRequestFormatSetExplicitly IsRequestFormatSetExplicitly

Obtiene la propiedad IsRequestFormatSetExplicitly.Gets the IsRequestFormatSetExplicitly property.

IsResponseFormatSetExplicitly IsResponseFormatSetExplicitly IsResponseFormatSetExplicitly IsResponseFormatSetExplicitly

Obtiene la propiedad IsResponseFormatSetExplicitly.Gets the IsResponseFormatSetExplicitly property.

Method Method Method Method

Obtiene y establece el método protocolar (por ejemplo, HTTP) al que la operación del servicio responde.Gets and sets the protocol (for example HTTP) method the service operation responds to.

RequestFormat RequestFormat RequestFormat RequestFormat

Obtiene y establece la propiedad RequestFormat.Gets and sets the RequestFormat property.

ResponseFormat ResponseFormat ResponseFormat ResponseFormat

Obtiene y establece la propiedad ResponseFormat.Gets and sets the ResponseFormat property.

TypeId TypeId TypeId TypeId

Cuando se implementa en una clase derivada, obtiene un identificador único para este Attribute.When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)
UriTemplate UriTemplate UriTemplate UriTemplate

La plantilla Identificador uniforme de recursos (URI) para la operación del servicio.The Uniform Resource Identifier (URI) template for the service operation.

Implementaciones de interfaz explícitas

IOperationBehavior.AddBindingParameters(OperationDescription, BindingParameterCollection) IOperationBehavior.AddBindingParameters(OperationDescription, BindingParameterCollection) IOperationBehavior.AddBindingParameters(OperationDescription, BindingParameterCollection) IOperationBehavior.AddBindingParameters(OperationDescription, BindingParameterCollection)

Implementa el método AddBindingParameters(OperationDescription, BindingParameterCollection).Implements the AddBindingParameters(OperationDescription, BindingParameterCollection) method.

IOperationBehavior.ApplyClientBehavior(OperationDescription, ClientOperation) IOperationBehavior.ApplyClientBehavior(OperationDescription, ClientOperation) IOperationBehavior.ApplyClientBehavior(OperationDescription, ClientOperation) IOperationBehavior.ApplyClientBehavior(OperationDescription, ClientOperation)

Implementa el método ApplyClientBehavior(OperationDescription, ClientOperation).Implements the ApplyClientBehavior(OperationDescription, ClientOperation) method.

IOperationBehavior.ApplyDispatchBehavior(OperationDescription, DispatchOperation) IOperationBehavior.ApplyDispatchBehavior(OperationDescription, DispatchOperation) IOperationBehavior.ApplyDispatchBehavior(OperationDescription, DispatchOperation) IOperationBehavior.ApplyDispatchBehavior(OperationDescription, DispatchOperation)

Implementa el método ApplyDispatchBehavior(OperationDescription, DispatchOperation).Implements the ApplyDispatchBehavior(OperationDescription, DispatchOperation) method.

IOperationBehavior.Validate(OperationDescription) IOperationBehavior.Validate(OperationDescription) IOperationBehavior.Validate(OperationDescription) IOperationBehavior.Validate(OperationDescription)

Implementa el método Validate(OperationDescription).Implements the Validate(OperationDescription) method.

IOperationContractAttributeProvider.GetOperationContractAttribute() IOperationContractAttributeProvider.GetOperationContractAttribute() IOperationContractAttributeProvider.GetOperationContractAttribute() IOperationContractAttributeProvider.GetOperationContractAttribute()
IWmiInstanceProvider.FillInstance(IWmiInstance) IWmiInstanceProvider.FillInstance(IWmiInstance) IWmiInstanceProvider.FillInstance(IWmiInstance) IWmiInstanceProvider.FillInstance(IWmiInstance)
IWmiInstanceProvider.GetInstanceType() IWmiInstanceProvider.GetInstanceType() IWmiInstanceProvider.GetInstanceType() IWmiInstanceProvider.GetInstanceType()
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Obtiene la información de tipos de un objeto, que puede utilizarse para obtener la información de tipos de una interfaz.Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Devuelve un valor que indica si esta instancia es igual que un objeto especificado.Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Devuelve el código hash de esta instancia.Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

Si se reemplaza en una clase derivada, indica si el valor de esta instancia es el valor predeterminado de la clase derivada.When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

Cuando se invalida en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Se aplica a