WCF服务端点与主机基本地址 [英] WCF Service Endpoints vs Host Base address

查看:79
本文介绍了WCF服务端点与主机基本地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我对服务端点和主机基地址的用途感到困惑.在到目前为止的所有示例中,我都讨论了使用必需的绑定设置端点的方法,您通常可以导航到这些端点

so i'm a litle confused over what the service endpoints and host base address is for. In all the examples i have walked through so far they talk about setting up the endpoints with the required bindings and you can normally navigate to those endpoints

但是,当我使用以下配置来设置和托管我的服务时,它似乎只公开了Hosts基址.

Hoever when i use the following config to set up and host my service it only seems to expose the Hosts base address.

    <configuration>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- When deploying the service library project, the content of the config file must be added to the host's
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <services>
          <service name="HostService.EvalService">
            <endpoint address="http://localhost:8080/basic"
              binding="basicHttpBinding" contract="HostService.IEvalService" />
            <endpoint address="http://localhost:8080/ws"
              binding="wsHttpBinding" contract="HostService.IEvalService" />
            <endpoint address="mex" binding="mexHttpBinding"
              name="mex" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8080/EvalsService" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>

有人可以向我解释吗?

推荐答案

在IIS上承载WCF服务时,基址只能是.svc文件的URL.如果您指定任何其他基址,则将其忽略.您仍然可以为端点指定相对URI,例如address="basic"address = "ws".然后,在这种情况下,端点上的地址变为<URL to the .svc file>/basic<URL to the .svc file>/ws.

When you host the WCF service on IIS, the base address can only be the URL to the .svc file. If you specify any other base address, it's ignored. You can still specify the relative URI for your endpoints, such as address="basic" or address = "ws". Then the address on the endpoint becomes <URL to the .svc file>/basic and <URL to the .svc file>/ws in this case.

这篇关于WCF服务端点与主机基本地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆