【问题标题】:WCF Metadata reference cannot be resolved无法解析 WCF 元数据引用
【发布时间】:2012-10-01 18:44:17
【问题描述】:

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

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

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

这是我的 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>

【问题讨论】:

    标签: wcf


    【解决方案1】:

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

    【讨论】:

    • 我面临同样的问题,但根据解决方案,我如何为 iis 分配临时 C:\Windows\Temp 的权限?步骤是什么?
    • 右键单击文件夹并将权限设置为运行网站的任何用户。或在 IUSR 帐户下。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-08
    相关资源
    最近更新 更多