2011-09-13 155 views
2

我是wcf的新手。我創建並承載了簡單的wcf服務iis 7.5使用教程http://debugmode.net/2010/09/07/walkthrough-on-creating-wcf-4-0-service-and-hosting-in-iis-7-5/在IIS7.5上託管WCF服務

一切正常,直到我試圖使用此服務。當我嘗試在我的客戶端添加服務引用它給了以下錯誤

Metadata contains a reference that cannot be resolved: 'http://localhost:4567/Service1.svc?wsdl'. The WSDL document contains links that could not be resolved. There was an error downloading 'http://localhost:4567/Service1.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://localhost:4567/Service1.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:4567/Service1.svc . 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.

我服務的web.config文件中包含

<?xml version="1.0"?> 
<configuration> 

<system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
</system.web> 
<system.serviceModel> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior> 

     <serviceMetadata httpGetEnabled="true"/> 

     <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
    </serviceBehaviors> 
</behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer> 
<modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 

+0

客戶端的wcf配置是什麼? –

+0

客戶端沒有wcf配置。在客戶端我mux試圖添加服務參考 – yrahman

回答

4

這通常是由一個例外是引起了一般性錯誤由服務拋出。不幸的是,因爲includeExceptionDetailInFaults在您的配置中設置爲false,所以您在客戶端上看不到任何使用該服務的soap異常詳細信息。

首先,在您的開發環境中設置includeExceptionDetailInFaults = "true",以便您可以看到任何其他異常詳細信息。接下來,嘗試使用瀏覽器並直接導航至http://localhost:4567/Service1.svc以查看是否顯示通用服務頁面。然後嘗試導航至http://localhost:4567/Service1.svc?wsdl以查看WSDL是否適當顯示。在這兩種情況下,服務引發的任何錯誤都應該拋到瀏覽器中。希望這能幫助你找到問題的根源。如果您仍然無法找出問題,請發佈您找到的任何其他信息。祝你好運!

+0

我已經試圖訪問它在瀏覽器上都描述的Url和它在瀏覽器中正常工作。我在web.config中將includeExceptionDetailInFaults更改爲true。並重新發布服務,並嘗試在客戶端添加引用,但它提供了完全相同的錯誤而沒有額外的細節。 – yrahman

+1

下一步是嘗試訪問xsd引發錯誤。嘗試在瀏覽器中導航到http:// localhost:4567/Service1.svc?xsd = xsd0以查看是否引發了任何錯誤。 – Capps