zoukankan      html  css  js  c++  java
  • 初探WCF 如何在配置文件中指定Address?

    相对地址
    <host>
              
    <baseAddresses>
                
    <add baseAddress = "http://localhost:8731/" />
              
    </baseAddresses>
      
    </host>
      
    <endpoint address ="Service1" binding="basicHttpBinding" contract="Wcf_Address_Config.IService1"></endpoint>
    这个WCF的实际地址:
    http://localhost:8731/Service1


    绝对地址
    <host>
              
    <baseAddresses>
                
    <add baseAddress = "http://localhost:8731/" />
              
    </baseAddresses>
       
    </host>
       
    <endpoint address ="http://localhost:8731/Service" binding="basicHttpBinding" contract="Wcf_Address_Config.IService1"> </endpoint>

    是绝对地址的时候,baseAddresses就不起作用了,实际地址就是endpoint中设置的地址


    在网上有人说绝对地址是通过将httpGetEnabled设置为true,并且设置httpGetUrl为绝对地址是在设置endPoint的说法有些不准确,因为在WCF中有两种地址,一种是访问endPoint时候用到地址,另外一种是服务描述的地址,服务描述在wcf中被称作serviceMetadata,通过它能够产生代理类,比如,我们做如下的设置:

     <serviceMetadata httpGetEnabled="True" httpGetUrl="http://localhost:8731/Service"/>

    只代表在http://localhost:8731/Service/?wsdl上能找到服务描述,可以通过http://localhost:8731/Service/?wsdl生成代理类,而不是将endPoint的地址设置为了http://localhost:8731/Service,这点一定要注意,不要受有些说法的误导。

  • 相关阅读:
    java--volatile关键字
    java--线程异常处理器
    java--线程池
    Supervisor安装和使用
    网络协议--HTTP
    1.Nginx简介
    Nginx配置实战
    Redis面试题
    SpringBoot--集成swagger2
    缓存的优缺点
  • 原文地址:https://www.cnblogs.com/weichuo/p/1233701.html
Copyright © 2011-2022 走看看