Can I call a WCF service without setting content-type?

妖精的绣舞 提交于 2019-12-06 04:18:56

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!