WCF,改变端点的baseAdress [英] WCF, changing the baseAdress of an endpoint

查看:148
本文介绍了WCF,改变端点的baseAdress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对下面的配置文件中的几个问题:

 < system.serviceModel>
  <绑定/>
  <服务>
    <服务behaviorConfiguration =WcfReporting.Service1Behavior
             NAME =WcfReporting.Service1>
      <端点地址=
                结合=basicHttpBinding的bindingConfiguration =
                合同=WcfReporting.IService1>
        <身份>
          < D​​NS值=本地主机/>
        < /身分>
      < /端点>
      <端点地址=MEX绑定=mexHttpBinding
                合同=IMetadataExchange接口/>
      <主机>
        < baseAddresses>
          <新增baseAddress =的net.tcp://本地主机:5050 //>
        < / baseAddresses>
      < /主机>
    < /服务>
  < /服务>
  <行为>
    < serviceBehaviors>
      <行为NAME =WcfReporting.Service1Behavior>
        <! - 为了避免泄露的元数据信息,下面设置为false值
             并删除元数据终结点上方展开之前 - >
        < serviceMetadata httpGetEnabled =真/>
        <! - 要接收调试目的的故障异常详细信息,
             下面设置为true值。设置为false部署之前,
             避免泄露异常信息 - >
        < serviceDebug includeExceptionDetailInFaults =FALSE/>
      < /行为>
    < / serviceBehaviors>
  < /行为>
< /system.serviceModel>
 

  1. 为什么当我按F5重新启动该服务,该服务启动与此网址的http://本地主机:2752 / ......何不5050我在baseAddresses规定。

  2. 如何如何添加另一个端点。我试图与端点地址=/地址2绑定=basicHttpBinding的合同=WcfReporting.IService1/>

我应该怎么能够访问该服务,不仅与的http://本地主机/ VirtualDir / 也与的http://本地主机/ VirtualDir /地址2 或它是如何工作的。

解决方案

如果你从Visual Studio 2005或更高版本内托管的卡西尼号,您可以使用指定端口项目/属性/网络/使用Visual Studio开发服务器/特定端口。

默认情况下,端口会自动分配 - 这不是Web服务非常有帮助你的客户可能会想使用一个固定的网址

您不必指定< baseAddresses>在配置文件中时,IIS或卡西尼托管 - 基本URL由Web服务器提供。在< baseAddresses>元素时使用自托管

i have a few questions about the below config file:

<system.serviceModel>
  <bindings />
  <services>
    <service behaviorConfiguration="WcfReporting.Service1Behavior"
             name="WcfReporting.Service1">
      <endpoint address="" 
                binding="basicHttpBinding" bindingConfiguration=""
                contract="WcfReporting.IService1">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" 
                contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://localhost:5050/" />
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="WcfReporting.Service1Behavior" >
        <!-- To avoid disclosing metadata information, set the value below to false 
             and remove the metadata endpoint above before deployment -->
        <serviceMetadata httpGetEnabled="true"/>
        <!-- To receive exception details in faults for debugging purposes, 
             set the value below to true. Set to false before deployment to 
             avoid disclosing exception information -->
        <serviceDebug includeExceptionDetailInFaults="false"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

  1. Why when I hit F5 to restart the service, the service starts with this URL http://localhost:2752/ ... why not 5050 as I specified in baseAddresses.

  2. How how can I add another endpoint. I tried with endpoint address="/Address2" binding="basicHttpBinding" contract="WcfReporting.IService1" />

should I how be able to access the service, not only with http://localhost/VirtualDir/ but also with http://localhost/VirtualDir/address2 or how does it work?

解决方案

If you're hosting in Cassini from within Visual Studio 2005 or later, you can specify the port using Project/Properties/Web/Use Visual Studio Development Server/Specific Port.

By default the port will be auto-assigned - which isn't very helpful for Web Services as your clients will probably want to be using a fixed URL.

You don't need to specify <baseAddresses> in the config file when hosting in IIS or Cassini - the base URL is provided by the web server. The <baseAddresses> element is used when self-hosting.

这篇关于WCF,改变端点的baseAdress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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