2012-08-15 116 views
0

刚刚部署了一个WCF项目到IIS。WCF内容类型不匹配

然而,当我尝试将服务引用添加到测试项目时,Visual Studio提供了以下:

The document was understood, but it could not be processed. 
    - The WSDL document contains links that could not be resolved. 
    - There was an error downloading 'http://server1.local/WCFServices/serv1/serv1.svc?xsd=xsd0'. 
    - The underlying connection was closed: An unexpected error occurred on a receive. 
    - Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. 
    - An existing connection was forcibly closed by the remote host 
    Metadata contains a reference that cannot be resolved: 'http://server1.local/WCFServices/serv1/serv1.svc?wsdl'. 
    Content Type application/soap+xml; charset=utf-8 was not supported by service http://server1.local/WCFServices/serv1/serv1.svc?wsdl. The client and service bindings may be mismatched. 
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. 
If the service is defined in the current solution, try building the solution and adding the service reference again. 

所以这是一个问题,我得八九不离十。服务的内容类型与客户期望的内容不匹配。

那么,我该如何解决它?

+0

你可以发布你的配置,包括mex端点吗? – CodingWithSpike 2012-08-15 11:28:29

回答

1

检查客户端的App.Config或Web.Config,并检查ServiceModel。最有可能有一个customBinding这是不同的WCF服务发送。

+0

它还没有配置文件! – CompanyDroneFromSector7G 2012-08-15 11:31:14

+0

然后你可能有这个问题; http://stackoverflow.com/questions/6673495/wcf-iis-server-configuration – 2012-08-15 11:36:16

+0

我认为你是对的!只是想弄清楚如何改变它现在... – CompanyDroneFromSector7G 2012-08-15 11:39:45

1

由于这是第一篇文章谷歌展示了这个错误,我要与我的解决方案参与:

我同时在运行良好的系统更改代码,但在更新在参考了类似的错误我的开发系统失败了。该引用位于silverlight项目内部,并与周围网站中集成的WCF相关(我猜是标准confiduration)。我的错误消息包含“WCF元数据包含无法解析的引用:'一些有趣的路径'。响应消息的内容类型text/html; charset = utf-8与绑定的内容类型不匹配(application/soap + xml; charset = utf-8)“。我的网站使用授权角色,即问题/解决方案的基础。为了更新服务参考,我必须允许所有用户:

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
     <!--<authorization> 
      <allow users="*"/>    
     </authorization>--> 
     <authorization> 
      <deny users="?"/> 
      <allow roles="role-1,role-2"/> 
      <deny users="*"/> 
     </authorization> 
    </system.web> 
</configuration>