2010-09-25 19 views
2

我有一个简单的WCF4 REST服务,在使用浏览器时工作正常。但是,当我尝试从VS2010中的其他项目添加服务引用时,出现错误消息:“HTML文档不包含Web服务发现信息。”如何使用WCF的新简化配置模型公开元数据

我的问题是,由于WCF4有一个新的简化配置模型,我找不到任何有关如何打开当前公开的标准端点的元数据交换端点的实例。

我试着添加一个条目,如下所示,但它没有解决问题。

这里是我的配置:

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
    <standardEndpoints> 
     <webHttpEndpoint> 
     <!-- 
      Configure the WCF REST service base address via the global.asax.cs file and the default endpoint via the attributes on the <standardEndpoint> element below 
     --> 
     <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/> 

     </webHttpEndpoint> 
     <mexEndpoint> 
     <standardEndpoint name=""/> 
     </mexEndpoint> 

    </standardEndpoints> 
    </system.serviceModel> 

任何援助将不胜感激。

里克

+1

基于REST的服务(的WebHttpBinding)没有(也可以通过元数据交换被曝光的元数据mex)协议。这是REST与SOAP的主要缺点之一... – 2010-09-25 21:44:02

回答

4

元数据端点暴露WSDL +描述SOAP服务的XSD。没有支持为REST公开元数据。 WCF不支持WADL(REST服务的描述)。

如果需要添加元数据以简单的构成SOAP服务,你需要添加这种行为:

<configuration> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 
+0

我在我的研究中学到了同样的东西。谢谢。 – rboarman 2010-09-26 19:36:28