【问题标题】:Role of baseAddress while configurting WCF Service EndPoint配置 WCF 服务端点时 baseAddress 的作用
【发布时间】:2013-06-02 11:21:20
【问题描述】:

我创建了简单的 WCF 服务并将其端点配置如下。

<services>
  <service name="AsynchWCFService.MathOperation">
    <endpoint address="MathsOperation" binding="wsHttpBinding" contract="AsynchWCFService.IMathOperation">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>            
        <add baseAddress="http://localhost:8080/OperationService/" />
      </baseAddresses>
    </host>
  </service>
</services>

我在一个独立的 exe 中托管了这个 WCF 服务。我希望可以通过以下地址访问我的服务。

http://localhost:8080/OperationService/MathsOperation/

但是可以通过http://localhost:8080/OperationService/获得服务

我想使用http://localhost:8080/OperationService/MathsOperation/ 链接访问服务。谁能帮帮我?

【问题讨论】:

  • 您是否尝试过指定绝对路径:&lt;endpoint address="http://localhost:8080/OperationService/MathsOperation/" ...
  • @rae1n 谢谢。我试过这个并且工作正常。但我只是想了解相对寻址的工作原理。

标签: wcf endpoint


【解决方案1】:

我认为http://localhost:8080/OperationService 不提供您的服务。您看到的只是一个由 WCF 创建的 HTML 页面,它描述了可用的 mex 端点或 WSDL 的路径。 这些 mex 端点描述了 WCF 服务的 ABC,其中 A = 地址 => http://localhost:8080/OperationService/MathsOperation/。潜在客户通过查询 mex 端点了解您的服务 url。

默认情况下,此 HTML 页面将显示在您的基本地址处。但是,您可以使用 serviceDebug 行为禁用此页面或将其设置为显示在不同的 url。

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceDebug httpHelpPageUrl="http://localhost:8080/OperationService/myhelppage"
                               /> <!-- use httpHelpPageEnabled="false" to disable the page -->
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

很遗憾,我认为您不能将 httpHelpPageUrl 设置为与您的服务端点相同的地址。

【讨论】:

猜你喜欢
  • 2011-09-19
  • 2016-02-28
  • 1970-01-01
  • 2022-01-16
  • 1970-01-01
  • 1970-01-01
  • 2012-09-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多