Request
POST http://127.0.0.1:8080/Marketing HTTP/1.1
Content-Type: application/xml
Host: 127.0.0.1:8080
Content-Length: 91
Expect: 100-continue
Connection: Keep-Alive
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/
">Phyllis Harris</string>
Response
HTTP/1.1 415 Cannot process the message because the content type
'application/xml' was not the expected type 'text/xml; charset=utf-8'.
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Date: Wed, 27 Oct 2010 20:00:06 GMT
I have done a fair bit of development with WCF but I had never seen this error message before. I was so sure that my code was correct I immediately assumed it must be a problem with our new HttpPost activity so first I decided to check with our test team to see if they had a working test. When I found out they did we began looking more closely and I found… a copy paste bug.
That’s right, in my hosting code it turned out that I was using ServiceHost instead of WebServiceHost to host my WCF WebHttp service. In most cases when service host detects that your service (or it’s configuration) is somehow invalid it throws an exception when you try to open the host. For some strange reason (bug?) in this case it does not throw an exception but happily starts accepting requests and throwing 415 when you invoke it.
Read more: The .NET Endpoint