I want to read the body of a HttpRequest received by a WCF web service.
The WCF web service looks like so:
[ServiceContract]
public interface ITestRestService
{
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/test")]
string Test(Stream aStrm);
}
The client that sends to this service successfully invokes the Test()
method but the aStrm
throws an exception:
'aStrm.ReadTimeout' threw an exception of type 'System.InvalidOperationException'
Should I be using the stream to send the body or something else?
I can send the data as part of the url when the configs for that contract look like so:
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "?s={aStr}")]
string Test(string aStr);
but is this common practice? shouldn't I logically be adding the content to the body of the request instead of the url?