Access Request Body in a WCF RESTful Service

Posted by urini on Stack Overflow See other posts from Stack Overflow or by urini
Published on 2009-08-17T12:53:53Z Indexed on 2010/05/04 19:18 UTC
Read the original article Hit count: 340

Filed under:
|
|
|
|

Hi,

How do I access the HTTP POST request body in a WCF REST service?

Here is the service definition:

[ServiceContract]
public interface ITestService
{
    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "EntryPoint")]
    MyData GetData();
}

Here is the implementation:

public MyData GetData()
{
    return new MyData();
}

I though of using the following code to access the HTTP request:

IncomingWebRequestContext context = WebOperationContext.Current.IncomingRequest;

But the IncomingWebRequestContext only gives access to the headers, not the body.

Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf