同事将好的 网站和wcf服务布置到目标服务器上,报错如下:
The remote server returned an error: (415) Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'..
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
这个错误报的是(415)不能处理的消息格式,因为客户端发送过去的是'text/xml; charset=utf-8' , 而系统期望的是'application/soap+xml; charset=utf-8'。 这个错误初步判断是因为双方通信协议不一致造成的, 查找客户端的We.bConfig中发现 果然同事在布置调试的时候,将endpoint中的binding 改错了, 将wsHttpBinding 改成了basicHttpBinding, 导致双方消息格式编码不一致。
正确的
<endpoint address="http://196.9.200.129:8008/Service" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService"
name="WSHttpBinding_IService1">
:
错误的
<endpoint address="http://196.9.200.129::8083/Service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService" contract="ServiceReference1.IService"
name="BasicHttpBinding_IService" >