2012-08-15 111 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>