错误:无法从WCF服务获取元数据

Exi*_*tos 37 c# wcf

我有一个成功运行的WCF服务,我可以使用javascript调用.但是,我想使用WCF测试客户端调用它,我很难做到这一点.我被告知需要确保我已在指定地址启用元数据发布.阅读文档后,我只是看不出我的意思是我的配置:

<system.serviceModel>
   <services>
       <service name="CommentSessionIDWCFService" 
                behaviorConfiguration="CommentSessionIDBehavior">
          <endpoint 
              address="" 
              behaviorConfiguration="CountryProvinceBehavior"
              binding="webHttpBinding" 
              contract="ICommentSessionIDWCFService" />
       </service>
   </services>
   <behaviors>
      <serviceBehaviors>
         <behavior name="CommentSessionIDBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="true"/>
         </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
          <behavior name="CountryProvinceBehavior">
              <webHttp/>
          </behavior>
      </endpointBehaviors>
   </behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

我已经阅读了其他帖子,但我看不出要填充什么,我只是不断收到错误.Q的..

1)我是否正确地说我需要在配置中配置一个完整的新服务来显示元数据?

2)如何添加配置以使此元数据发布,以便我可以与客户端一起调用?

Men*_*hem 50

您需要一个服务的元数据端点,这是一个示例.

<services>
    <service name="MyService" behaviorConfiguration="MEX">
    <endpoint
        address="http://localhost:8000/MEX"
        binding="mexHttpBinding"
        contract="IMetadataExchange"
    />
    </service>
</services>

<behaviors>
    <serviceBehaviors>
        <behavior name="MEX">
            <serviceMetadata/>
        </behavior>
    </serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)

  • 无论谁投票给这个答案,请提供这样做的理由. (15认同)