Hosting WCF service on IIS7.5

泄露秘密 提交于 2020-01-02 10:23:12

问题


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>


回答1:


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!



来源:https://stackoverflow.com/questions/7401863/hosting-wcf-service-on-iis7-5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!