本文介绍了无法解析 WCF 元数据引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了无法通过 URL 在 Visual Studio 2010 中添加服务引用的问题.

I am having an issue where I can't add a service reference in Visual Studio 2010 via a URL.

我设置了 HOST 文件以在本地解析 http://mydomain.com,并设置我的 web.config 文件引用此网址.但是,当我通过 URL 添加服务引用时,出现以下错误:

I have my HOST file setup to resolve http://mydomain.com locally, and setup my web.config file to reference this url. However when I go to add a service reference by URL I get the following error:

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.

其他 URL 工作正常:http://mydomain.com/myservice.svc?wsdlhttp://mydomain.com/myservice.svc

The other URLS work fine:http://mydomain.com/myservice.svc?wsdl and http://mydomain.com/myservice.svc

这是我的 web.config 文件:

Here is my web.config file:

<?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 文件夹具有权限.没有它,它就无法生成所需的元数据.

The solution to this problem is that IIS needs to have rights to the C:\Windows\Temp folder. Without this it can't generate the meta data needed.

这篇关于无法解析 WCF 元数据引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 03:12