[OperationContract]
[WebInvoke(UriTemplate = "s={s}", Method = "POST")]
string EchoWithPost(string s);
I'm trying to consume this method (WCF service) using a WebRequest:
WebRequest request1 = WebRequest.Create("http://MyIP/Host");
request1.Method = "POST";
request1.ContentType = "application/x-www-form-urlencoded";
string postData1 = "s=TestString";
I don't want to pass the data (s=TestString) in the url, what I'm trying to do is passing the data in the message body.
First you need to change your service contract like this:
Notice how the
UriTemplateis no longer expecting any variable value in the URL.To invoke such an operation from a client: