本文介绍了WCF - 无法获取元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它在使用 IIS 7 的 Intranet 中运行,每当我在 IIS 管理器中启用匿名身份验证时它都能正常工作.如果我禁用它并尝试使用 wcftestclient 运行它,则会出现以下错误,
It is running in an Intranet using IIS 7 and it works fine whenever I enable Anonymous Authentication in the IIS Manager. If I disable it and try to run it using wcftestclient then I get the following error,
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 文件,
This is my web.config file,
<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 端点填充元数据.因此,欢迎任何建议.
As you can see I'm populating metadata using mexHttpBinding endpoint. So any advice is welcome.
谢谢,m0dest0.
Thank you,m0dest0.
推荐答案
移除 MEX 端点并离开 .Mex 端点需要启用匿名身份验证.
Remove the MEX endpoint and leave . Mex endpoints require anonymous authentication to be enabled.
这篇关于WCF - 无法获取元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!