【问题标题】:WCF- Meta Data Exchange ConfigurationWCF-元数据交换配置
【发布时间】:2011-01-26 06:59:31
【问题描述】:

我在 App.Config 文件中将两个端点定义为

 <system.serviceModel>
    <services>
      <service 
              name="HostDirectAddress.ITestService" 
              behaviorConfiguration="behaviorConfig">

      <endpoint 
                address="net.tcp://localhost:9000/ITestService"
                binding="netTcpBinding"
                contract="HostDirectAddress.ITestServiceContract"/>

    <endpoint
                address="http://localhost:9000/mex"
                binding="mexHttpBinding"
                contract="IMetadataExchange" />

    </service>
   </services>
        <behaviors>
           <serviceBehaviors>
            <behavior name="behaviorConfig">
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="True"/>
            </behavior>
          </serviceBehaviors>
 </behaviors>
</system.serviceModel>

我的客户来电

static void Main(string[] args)
{
      ServiceHost host = 
        new ServiceHost(typeof(HostDirectAddress.ITestService));
      host.Open();
      Console.WriteLine("....Service is Ready to Consume...");
      Console.ReadLine();
 }

我在尝试启动主机时收到以下错误

ServiceMetadataBehavior 的 HttpGetEnabled 属性设置为 true,HttpGetUrl 属性是相对地址,但没有 http 基地址。要么提供一个 http 基地址,要么将 HttpGetUrl 设置为一个绝对地址。

如何解决?

【问题讨论】:

    标签: asp.net wcf hosting


    【解决方案1】:

    错误信息告诉你如何修复它!

    1) 添加基地址

    <service 
        name="HostDirectAddress.ITestService" 
        behaviorConfiguration="behaviorConfig">
        <host>
           <baseAddresses>
              <add baseAddress="http://localhost:9000/" />
           </baseAddresses>
        </host>
        <endpoint
                address="mex"
                binding="mexHttpBinding"
                contract="IMetadataExchange" />
    

    或者:

    2)在你的服务行为中定义一个固定完整的HTTP地址:

    <behavior name="behaviorConfig">
        <serviceMetadata 
            httpGetEnabled="true"
            httpGetUrl="http://localhost:9000/mex" />
        <serviceDebug includeExceptionDetailInFaults="True"/>
    </behavior>
    

    做一个或另一个 - 事情应该可以正常工作。

    【讨论】:

      猜你喜欢
      • 2022-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-07
      • 1970-01-01
      • 1970-01-01
      • 2012-02-14
      相关资源
      最近更新 更多