WCF – The incoming message has an unexpected message format ‘Raw’

I was testing out my own WCF REST Service using Fiddler and was getting error response “The incoming message has an unexpected message format ‘Raw'”.

After spending time diagnosing the message the clue was, the WCF was getting a request with no content type.

My contract was specifically expecting the request format to be XML using the following attribute

RequestFormat = WebMessageFormat.Xml

Hence added the content type as “application/xml” and things went fine.

The following is an example of Fiddler’s request for a REST POST with composite data type

Type: POST
URL: http://localhost:1510/GalleryService.svc/RestService/GetDataUsingDataContract/
Protocol: HTTP/1.1

Request Header:

User-Agent: Fiddler
Host: localhost:1510
Content-Length: 198
Content-Type: application/xml

Request Body:

<CompositeType xmlns="http://schemas.datacontract.org/2004/07/Net.BinaryBits.Apps.BBGallery.WebService"><BoolValue>true</BoolValue><StringValue>String content</StringValue></CompositeType>

Leave a Reply

Your email address will not be published / Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.