So, I have been messing around with webservices for a while now, and I keep getting back to some basics, that I never seem to get right.
When u
I found out the answer. This is how to define a method, that can take the raw data sent in a HTTP POST:
[OperationContract]
[WebInvoke(BodyStyle=WebMessageBodyStyle.Bare)]
Stream PutMessage(Stream data);
and the implementation is like this:
public Stream PutMessage(Stream data)
{
byte[] buffer = new byte[65535];
int bytesRead, totalBytes = 0;
do
{
bytesRead = data.Read(buffer, 0, 65535);
totalBytes += bytesRead;
}
while (bytesRead > 0);
// Then you could interpret it as a String for example:
string jsonString = Encoding.UTF8.GetString(buffer, 0, totalBytes);
// yada yada
}