【问题标题】:Configure WCF host servce配置 WCF 主机服务
【发布时间】:2012-02-14 17:58:13
【问题描述】:

我有一个关于 Host app.config 文件配置的基本问题

假设我在电脑上托管我的 WCF 服务,其 IP 为:123.456.789.001:9999

这是我的 app.config 文件:

<configuration>

<services>
  <service name="Service.WebexClient" behaviorConfiguration="MyServiceTypeBehaviors"   >
    <host>
      <baseAddresses>
        <add baseAddress="http://<What should I put here>:9999/MyWebexService"/>
      </baseAddresses>
    </host>
  </service>

</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyServiceTypeBehaviors" >
     <serviceDebug includeExceptionDetailInFaults="true"/> 
<serviceMetadata httpGetEnabled="true"  httpGetUrl="http://<And What should I put here>:9999/MyWebexService/Help"/>

</behavior>
  </serviceBehaviors>
</behaviors>

我想知道应该在 baseAddress 和 httpGetUrl 中插入哪些正确的参数。我很迷惑。我应该放“localhost”还是ip(123.456.789.001)?

【问题讨论】:

    标签: c# wcf web-services host


    【解决方案1】:

    我相信您会使用端点的 IP 地址和 httpGetUrl 的 WSDL:

    <baseAddresses>         
      <add baseAddress="http://123.456.789.001:9999/MyWebexService"/>
    </baseAddresses> 
    
    <behavior name="MyServiceTypeBehaviors" >         
      <serviceDebug includeExceptionDetailInFaults="true"/>     
      <serviceMetadata httpGetEnabled="true" httpGetUrl="http://123.456.789.001:9999/MyWebexService?wsdl"/>        
    </behavior>    
    

    【讨论】:

    • 我不这样做是正确的:123.456.789.001:9999/MyWebexService?wsdl 问:在我的排队应用程序上调用 ServiceHost.Open() 会引发以下异常: System.ArgumentException: A base address cannot contain a URI query string .为什么?答:检查配置文件和代码中的队列 URI。虽然 MSMQ 队列支持使用“?”字符,URI 将此字符解释为字符串查询的开始。为避免此问题,请使用不包含“?”的队列名称字符。
    • 第一个问题 - 你在使用 MsmqBinding 吗?如果是,为什么要使用 http: 作为地址的协议?
    • 那么我上面的内容应该可以工作 - 您发布的评论似乎特定于 NetMsmqBinding。你试过我的答案吗?如果它不起作用,它会给你任何错误吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-31
    • 2010-12-07
    • 2010-10-19
    相关资源
    最近更新 更多