c# - WCF - 无法获取元数据

标签 c# wcf wcf-binding wcf-security wcftestclient

它使用 IIS 7 在 Intranet 中运行,只要我在 IIS 管理器中启用匿名身份验证,它就可以正常工作。如果我禁用它并尝试使用 wcftestclient 运行它,那么我会收到以下错误,

Error: Cannot obtain Metadata from http://myserver/testing/eval.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error    URI: http://myserver/testing/eval.svc    Metadata contains a reference that cannot be resolved: 'http://myserver/testing/eval.svc'.    The HTTP request is unauthorized with client authentication scheme 'Anonymous'. 

这是我的 web.config 文件,

<system.serviceModel>
<bindings>
    <wsHttpBinding>
        <binding name="Binding1">
            <security mode="Transport">
                <transport clientCredentialType="Windows" />
                <message establishSecurityContext="true" />
            </security>
        </binding>
    </wsHttpBinding>
    <basicHttpBinding>
        <binding name="httpBinding">
            <security mode="Transport">
                <transport clientCredentialType="Windows" />
            </security>
        </binding>
    </basicHttpBinding>     
</bindings>

<services>
  <service behaviorConfiguration="ServiceBehavior" name="EvalServiceLibrary.EvalService">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="Binding1" contract="EvalServiceLibrary.IEvalService">
      <identity>
        <dns value="myserver.mydomain.com" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="basic" binding="basicHttpBinding" contract="EvalServiceLibrary.IEvalService" />
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <!-- 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>

如您所见,我正在使用 mexHttpBinding 端点填充元数据。所以欢迎任何建议。

谢谢, m0dest0。

最佳答案

删除 MEX 端点并保留 . Mex 端点需要启用匿名身份验证。

关于c# - WCF - 无法获取元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10361013/

相关文章:

c# - 使用 OData 是个好主意吗?

wcf - NetCFSvcUtil "Error: An error occurred in the tool."

c# - 使用 msmq 和 wcf

c# - 在客户端和服务端应用异步等待的区别

javascript - OnClientClick 不起作用

c# - 即使我关闭了应用程序,我的 winform 应用程序仍在后台运行

c# - Wcf 并行和异步调用?

wcf - WCF Rest 服务的 SSL 实现

WCF:如何使用 AllowInsecureTransport

c# - WCF 需要哪种类型的安全性