我创建了承载IIS 6(Windows XP(的WCF服务:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehaviors">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Namespace.Class" behaviorConfiguration="myServiceBehaviors">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
我已经使用Visual Studio 2010创建了虚拟目录(MyVirtualFolder(,当我将浏览器指向"http://localhost/MyVirtualFolder/MyService.svc"我得到一个错误页面,告诉我我应该打开metadataExchange的接口,并说明如何做到这一点,如何修改我的配置文件。我仔细检查了一下,我的配置等于html页面提出的配置。
为什么IMetaDataExchange接口不可用?
提前谢谢!
尝试<serviceMetadata />
而不是<serviceMetadata httpGetEnabled="true"/>
如果您在IIS中托管web服务,则您有一个*.svc文件。你不需要一个端点来获取元数据,删除端点,一切都会很好。。
从IMetadataExchange
端点中删除address="mex"
。
此外,您的服务本身没有实际的端点。
如果可能,请尝试使用SvcConfigEditor,WCF配置编辑器(Windows SDK的一部分(来获得可用的服务和客户端配置。
最后我发现了原因:
<service name="Namespace.Class">
指向错误的类:(