2

I'm trying to replace a legacy REST/plain old xml web service with a WCF one using webHttpBinding. It MUST be backwards compatible with existing clients - which currently do not send a content-type header in the requests.

When I point my clients at my new web service I get HTTP ERROR 415 - missing content type.

Is it possible to configure WCF so it will accept raw requests without a content-type header?

jmiserez
  • 2,991
  • 1
  • 23
  • 34
deltanine
  • 1,166
  • 1
  • 13
  • 25

2 Answers2

1

415 is not "missing content type", it is 415 Unsupported Media Type. That infers that the server IS receiving a content-type, it just does not know how to handle it. According to the HTTP spec, proving a content-type is a SHOULD. not a MUST, so the WCF SHOULD accept a request with no content-type. If it doesn't, maybe you want to consider using the newer WCF Web API because they do follow the HTTP spec and allow you to pass content without a content-type header.


update:

Apparently this was a bug in earlier version of the .Net framework and there is a workaround/fix https://connect.microsoft.com/wcf/feedback/details/475964/content-type-header-validated-at-the-transport-level-instead-of-the-application-level-and-trows-a-415-exception

Darrel Miller
  • 139,164
  • 32
  • 194
  • 243
  • I have tried the solution in the above article, however it only solves the situation where WCF incorrectly handles the content-type on a POST. It does not resolve the issue if there is no content-type header. – deltanine May 20 '11 at 00:22
  • Are you using .Net 4 or 3.5 ? – Darrel Miller May 20 '11 at 01:02
  • 3.5 - this bug is fixed in .net 4.0. http://connect.microsoft.com/wcf/feedback/details/475964/content-type-header-validated-at-the-transport-level-instead-of-the-application-level-and-trows-a-415-exception this poster apparently solved the issue by writing a custom HttpTransportChannel and HttpListener, but this seems like a lot of effort to fix what seems like a simple problem. – deltanine May 20 '11 at 05:00
0

Under .net 3.5 the answer is NO. It seems that content-type is incorectly validated at the transport layer, instead of the application layer. The only way to get around this is to use a custom binding with a custom HtppTransportChannel.

This bug is fixed in .net 4.0

deltanine
  • 1,166
  • 1
  • 13
  • 25