无法解析WCF元数据引用

问题描述:

我遇到了无法通过URL在Visual Studio 2010中添加服务引用的问题。无法解析WCF元数据引用

我有我的HOST文件设置来解决http://mydomain.com本地,并设置我的web.config文件引用此网址。然而,当我去通过网址添加我收到以下错误服务引用:

Metadata contains a reference that cannot be resolved: 'http://mydomain.com/myservice.svc?wsdl'. 

The WSDL document contains links that could not be resolved. 

There was an error downloading 'http://mydomain.com/myservice.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://mydomain.com/myservice.svc'. 

There was no endpoint listening at http://mydomain.com/myservice.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. 

The remote server returned an error: (404) Not Found. 

其他网址的精细工作: http://mydomain.com/myservice.svc?wsdlhttp://mydomain.com/myservice.svc

这里是我的web.config文件:

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

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

    <services> 
     <!-- Note: the service name must match the configuration name for the service implementation. --> 
     <service name="FuncWS.Email" behaviorConfiguration="ServiceType" > 
     <!-- Add the following endpoint. --> 
     <endpoint address="myservice.svc" binding="webHttpBinding" contract="FuncWS.IEmail"></endpoint> 
     <!-- Note: your service must have an http base address to add this endpoint. --> 
     <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://mydomain.com"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceType"> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

此问题的解决方案是IIS需要拥有C:\ Windows \ Temp文件夹的权限。没有这个,它不能生成所需的元数据。

+0

刚刚遇到这个问题,感谢您的解决方案! – 2011-11-16 18:44:33

+0

也为我排序,谢谢 – Marcus 2011-12-08 15:53:35

+0

我面临着同样的问题,但根据解决方案,我如何将权限分配给临时C:\ Windows \ Temp for iis?步骤是什么? – 2012-06-14 10:21:02