在IIS7.5上托管WCF服务 [英] Hosting WCF service on IIS7.5

查看:64
本文介绍了在IIS7.5上托管WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是wcf的新手.我已经使用

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

元数据包含无法解析的引用: 'http://localhost:4567/Service1.svc?wsdl'. WSDL文档包含 链接无法解决.下载时出错 'http://localhost:4567/Service1.svc?xsd = xsd0'.底层 连接已关闭:接收时发生意外错误. 无法从传输连接中读取数据:现有 远程主机强行关闭了连接.现有的 远程主机强行关闭了连接元数据包含一个 无法解析的参考: 'http://localhost:4567/Service1.svc'.内容类型 application/soap + xml;服务不支持charset = utf-8 http://localhost:4567/Service1.svc .客户端和服务绑定 可能不匹配.远程服务器返回错误:(415)无法 处理消息,因为内容类型为'application/soap + xml; charset = utf-8'不是预期的类型'text/xml; charset = utf-8'.如果 该服务是在当前解决方案中定义的,请尝试构建 解决方案,然后再次添加服务引用.

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包含

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>

推荐答案

这是一般错误,通常是由于服务抛出异常而引起的.不幸的是,由于includeExceptionDetailInFaults在配置中设置为false,因此在使用该服务的客户端上看不到任何肥皂异常详细信息.

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.

首先,在开发环境中设置includeExceptionDetailInFaults = "true",以便您可能会看到任何其他异常详细信息.接下来,尝试使用浏览器并直接导航到 http://localhost:4567/Service1.svc 到查看是否显示常规服务页面.然后尝试导航到 http://localhost:4567/Service1.svc?wsdl 以查看是否正确显示WSDL.在两种情况下,服务引发的任何错误均应引发给浏览器.希望这可以帮助您找到问题的根本原因.如果您仍然无法解决问题,请张贴您发现的所有其他信息.祝你好运!

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!

这篇关于在IIS7.5上托管WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆