在IIS7.5上托管WCF服务
我是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>
这通常是由一个例外是引起了一般性错误由服务抛出。不幸的是,因为includeExceptionDetailInFaults
在您的配置中设置为false,所以您在客户端上看不到任何使用该服务的soap异常详细信息。
首先,在您的开发环境中设置includeExceptionDetailInFaults = "true"
,以便您可以看到任何其他异常详细信息。接下来,尝试使用浏览器并直接导航至http://localhost:4567/Service1.svc以查看是否显示通用服务页面。然后尝试导航至http://localhost:4567/Service1.svc?wsdl以查看WSDL是否适当显示。在这两种情况下,服务引发的任何错误都应该抛到浏览器中。希望这能帮助你找到问题的根源。如果您仍然无法找出问题,请发布您找到的任何其他信息。祝你好运!
客户端的wcf配置是什么? –
客户端没有wcf配置。在客户端我mux试图添加服务参考 – yrahman