WCF MEX端点

时间:2012-01-26 17:45:06

标签: wcf

我正在尝试将MEX端点添加到我的服务中。当我开始服务时,我正在

  

WCF服务主机找不到任何服务元数据。这可能会导致   客户申请   运行不正常。请检查元数据是否已启用。你想要_____吗   出口?

这是我的配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>

  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary1.CustomerService"
               behaviorConfiguration="Metadata">

        <endpoint address="" 
                  binding="wsHttpBinding" 
                  contract="WcfServiceLibrary1.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <endpoint address="mex" 
                  binding="mexHttpBinding" 
                  contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000" />
          </baseAddresses>
        </host>

      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="Metadata">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

任何人都知道为什么我仍然收到消息?

由于

1 个答案:

答案 0 :(得分:1)

您不必指定mex端点和httpGetEnabled。只需要一个公开元数据。不要指定httpGetUrl,因为这取决于您的托管环境。

试试这个..

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>

  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary1.CustomerService"
               behaviorConfiguration="Metadata">

        <endpoint address="" 
                  binding="wsHttpBinding" 
                  contract="WcfServiceLibrary1.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <endpoint address="mex" 
                  binding="mexHttpBinding" 
                  contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000" />
          </baseAddresses>
        </host>

      </service>
    </services>   
  </system.serviceModel>

</configuration>