1

我在 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>

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

4

1 回答 1

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>
于 2013-05-17T14:51:56.947 回答