WCF测试客户端 - 无法获取元数据

时间:2013-05-17 14:39:38

标签: c# wcf

我在c#中遇到wcf问题。我收到错误消息:“无法获取元数据”。 我试图谷歌并在这里检查类似的帖子,但我似乎无法找出什么是错的。这是我的App.config文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="SearchService.PersonServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="SearchService.PersonServiceBehavior"
            name="SearchService.PersonService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="" contract="SearchService.IPersonService">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:8731/Design_Time_Addresses/SearchService/PersonService/" />
                </baseAddresses>
            </host>
        </service>
    </services>
</system.serviceModel>

如果有人能找到解决办法或指导我朝正确方向前进,我将非常高兴:)

1 个答案:

答案 0 :(得分:0)

前一段时间我遇到过类似的问题,查看我的配置文件,我唯一能看到的是我使用的是WebBehavior(请参阅下文)

<system.serviceModel>
<services>
  <service behaviorConfiguration="ServiceBehaviour" name="MyCRMServiceHost.MyCRMService">
    <endpoint address="/imo" behaviorConfiguration="webBehavior"
      binding="webHttpBinding" name="IMOEndpoint" contract="MyCRMServiceHost.IGenerateIMO" />
    <endpoint address="mex" binding="mexHttpBinding" name="MEXEndpoint"
      contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="webBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

</system.serviceModel>