I have a wcf service defined like this:
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json)]
public CreateOrderResponse CreateOrder(CreateOrderRequest request)
The request parameter is populated fine, but inside my method a what to access HttpContext.Current.Request.InputStream to get the raw post body but the InputStream is empty, InputStream.Lenght is 0.
My question is why is Request.InputStream empty when the request parameter is populated fine from the post request?
You need to use the CreateOrderRequest instance and it’s associated properties.
As far as I know, and I may be wrong, the Inputstream would always be null as it has been processed prior to being passed to your WCF method. See this link for more information Capturing raw HTTP POST Data during Exception