在IIS7.5上托管WCF服务
我是wcf新手。我使用 http://debugmode.net/2010/09/07/walkthrough-on-creating-wcf-4-0-service-and-hosting-in-iis-7-5/
一切都很顺利,直到我尝试使用这项服务。当我尝试在客户端中添加服务引用时,出现以下错误
元数据包含无法解析的引用: 'http://localhost:4567/Service1.svc?wsdl'。 WSDL 文档包含 无法解析的链接。下载时出现错误 'http://localhost:4567/Service1.svc?xsd=xsd0'。底层的 连接已关闭:接收时发生意外错误。 无法从传输连接读取数据:现有的 连接被远程主机强制关闭。现有的 连接被远程主机强制关闭 元数据包含 无法解决的参考: 'http://localhost:4567/Service1.svc'。内容类型 应用程序/soap+xml;服务不支持 charset=utf-8 http://localhost:4567/Service1.svc。客户端和服务绑定 可能不匹配。远程服务器返回错误:(415) 无法 处理消息,因为内容类型为“application/soap+xml”; charset=utf-8' 不是预期的类型 'text/xml;字符集=utf-8'。如果 该服务是在当前解决方案中定义的,请尝试构建 解决方案并再次添加服务引用。
我的服务的 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>
i am new to wcf. i have created and hosted simple wcf service on iis 7.5 using tutorial from http://debugmode.net/2010/09/07/walkthrough-on-creating-wcf-4-0-service-and-hosting-in-iis-7-5/
all goes fine until i tried to consume this service. when i try to add service reference in my client it gives following error
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 of my service contains
<?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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一般错误,通常由服务引发的异常引起。不幸的是,由于
includeExceptionDetailInFaults
在您的配置中设置为 false,因此您在使用该服务的客户端上看不到任何肥皂异常详细信息。首先,在您的开发环境中设置
includeExceptionDetailInFaults = "true"
,以便您可以看到任何其他异常详细信息。接下来,尝试使用浏览器并直接导航到 http://localhost:4567/Service1.svc查看是否显示通用服务页面。然后尝试导航到 http://localhost:4567/Service1.svc?wsdl 看看是否WSDL 已正确显示。在这两种情况下,服务抛出的任何错误都应该抛出到浏览器。希望这有助于您找到问题的根本原因。如果您仍然无法解决问题,请发布您找到的任何其他信息。祝你好运!This is a generic error usually caused by an exception being thrown by the service. Unfortunately, since
includeExceptionDetailInFaults
is set to false in your config, you do not see any soap exception details on your client consuming the service.First, set
includeExceptionDetailInFaults = "true"
in your development environment so you may see any additional exception details. Next, try to use a browser and navigate directly to http://localhost:4567/Service1.svc to see if the generic service page is displayed. Then try to navigate to http://localhost:4567/Service1.svc?wsdl to see if the WSDL is appropriately displayed. Any errors being thrown by the service should be thrown to the browser in both situations. Hopefully, this helps lead you to the root cause of your problem. Please post any additional information you find if you still cannot figure out the problem. Good luck!