0

刚刚将 WCF 项目部署到 IIS。

但是,当我尝试将服务引用添加到测试项目时,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.

所以有一个问题,我有点明白。服务的内容类型与客户的期望不匹配。

那么,我该如何解决呢?

4

2 回答 2

1

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

于 2012-08-15T11:30:21.043 回答
1

由于这是 google 出现此错误的第一篇文章,我想参与我的解决方案:

我在更改运行良好的系统中的代码时遇到了类似的错误,但更新我的开发系统上的引用失败。该参考位于 silverlight 项目中,并且与集成在周围网站中的 WCF 相关(我猜是标准配置)。我的错误消息包括“WCF 元数据包含无法解析的引用:'一些有趣的路径'。响应消息的内容类型 text/html;charset=utf-8 与绑定的内容类型不匹配(应用程序/soap +xml;字符集=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>
于 2014-10-20T13:38:20.513 回答