15 49.0138 8.38624 1 0 4000 1 https://www.alexmedina.net 300 true 0

WCF REST, un OperationContract con GET y otro con POST

0 Comments

A veces por motivos de seguridad o eficiencia hay que configurar las llamadas WCF REST por GET o por POST, es altamente recomendable que las peticiones GET al servidor se hagan por GET y las SET por POST, por motivos de seguridad sobretodo. Por eficiencia es siempre mejor el GET.

[ServiceContract]
public interface IGasPriceService
{
    [OperationContract]
    [WebGet // ESTO ES PARA UN GET
        (RequestFormat = WebMessageFormat.Xml,
        ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = "/GetGasPrice/For/City/{city}"
        )]
    GasPriceData GetPriceDataForCity(string city);

    [OperationContract]
    [WebInvoke // ESTO PARA UN POST
        (Method = "POST",
        RequestFormat = WebMessageFormat.Xml,
        UriTemplate = "/SetGasPrice/For/ZipCode/{zipCode}/Price/{price}"
        )]
    void SetPriceDataForZipCode(string zipCode, string price);
}

 

Previous Post
Configurar el tamaño de las peticiones WCF REST del servicio web
Next Post
Utilizar Parallels Extensions de System.Threading en Framework .NET 3.5

0 Comments

Leave a Reply

SOBRE MÍ

Afortunado de trabajar en lo que me gusta, aprendiendo cada día cosas nuevas y ayudando a crear proyectos.
Conocimientos en diversas tecnologías y experiencia demostrable.
¿Nos ponemos manos a la obra?

Mis Apuntes