2014-01-23 23 views
0

我已添加帮助页面端点,如example on MSDN,我的元数据交换端点停止工作。这里异常的详细信息,当我尝试看到的元数据http://imgur.com/delete/HYe9c9OocABgxOj如果没有这一切的伟大工程,但我需要附上您的mex端点帮助页面WCF配置元数据交换和帮助页面端点

<system.serviceModel>  
    <services> 
     <service behaviorConfiguration="MyServiceBehaviors" name="GoalTracker.WcfRestService.Service1"> 
      <endpoint address="mex" binding="mexHttpBinding" contract="GoalTracker.WcfRestService.IService1" /> 

      <endpoint address="" binding="webHttpBinding" contract="GoalTracker.WcfRestService.IService1" /> 
      <endpoint address="Help" kind="webHttpEndpoint" 
       behaviorConfiguration="RESTEndpointBehavior" 
       contract="GoalTracker.WcfRestService.IService1" /> 
     </service> 

    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="MyServiceBehaviors"> 
       <!-- Add the following element to your service behavior configuration. --> 
       <serviceMetadata httpGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="True" 
           httpHelpPageEnabled="True"/> 
      </behavior> 
     </serviceBehaviors>   
     <endpointBehaviors> 
      <behavior name="RESTEndpointBehavior"> 
       <webHttp helpEnabled="true"/> 
      </behavior> 
     </endpointBehaviors> 
    </behaviors>  
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

回答

1

合同应IMetadataExchange但是,我不知道为什么你需要mex端点为您服务是基于REST的。

通过在端点行为中设置helpEnabled="true",帮助页面将自动启用。您不需要添加具有"Help"地址的其他端点。请删除该端点。

在主要端点上设置kind="webHttpEndpoint"behaviorConfiguration="RESTEndpointBehavior",其中address=""

因此,它应该是这样的:

<service behaviorConfiguration="MyServiceBehaviors" name="GoalTracker.WcfRestService.Service1"> 

     <endpoint address="" kind="webHttpEndpoint" 
      behaviorConfiguration="RESTEndpointBehavior" 
      contract="GoalTracker.WcfRestService.IService1" /> 

</service> 
+0

我只IService1合同有discribed我API的 – Ark

+0

正确的 - 但是,如果你暴露了'mex'端点'mexHttpBinding'它应该有'IMetadataExchange'为合同。这是WCF内置的合同。或者,如果您不希望Mex端点 - REST服务通常不需要 - 您可以删除该端点。 – YK1

+0

当我用mexHttpBinding公开mex端点时,IMetadataExchange不会改变行为。我也可以像使用IService1一样删除使用IMetadataExchange的帮助页面端点和mex。我看到这对他来说不重要。但它仍不能解决我的问题。我无法使用帮助和mex端点 – Ark