I have a web service with both SOAP and REST endpoints. I have to accept requests from a client that I do not have any control over on my REST endpoint. Currently the client gets a 400 response and the tracelog on my server shows this error:
The incoming message has an unexpected message format 'Raw'.
The expected message formats for the operation are 'Xml', 'Json'.
I’ve tried everything I can think of with the WebContentTypeMapper but seem to end up right where I started every time. The request from the client doesn’t appear to be well formed XML or JSON so if I try to force XML or JSON types from the WebContentTypeMapper I end up with parser errors.
So I guess I need to find out if I can force this endpoint to accept the message anyway. That should be easy, right guys? …guys? …right?
If you make the operation take a stream then you can analyse the incoming data yourself and work out what to do with it. The ContentType of the HTTP request should tell you what is in the stream
As an example, say you had a service which allowed you to upload images. You may want to perform different kinds of image processing depending on the image type. So we have a service contract as follows:
The implementation checks the Content type of the request and performs processing dependent on it: