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);
}