<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    我是FE,也是Fe

    前端來(lái)源于不斷的點(diǎn)滴積累。我一直在努力。

    統(tǒng)計(jì)

    留言簿(15)

    閱讀排行榜

    評(píng)論排行榜

    Spring+CXF配置HTTP代理訪問(wèn)Internet

    一個(gè)典型的CXF Webservice項(xiàng)目部署到正式環(huán)境后,服務(wù)器不能訪問(wèn)外網(wǎng),只能通過(guò)代理訪問(wèn)外網(wǎng),找了很多資料,剛開(kāi)始想法是不用Spring的配置文件,直接用java編程訪問(wèn)webservice。在java的Http請(qǐng)求中使用代理的方法如下:

    String authentication="username:password";//用戶(hù)+”:”+密碼
            String encodedLogin= new BASE64Encoder().encode(authentication.getBytes());
            Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("IP", PORT));
            
            HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(proxy );
            conn.setRequestProperty("Proxy-Authorization", " Basic " + encodedLogin);

    使用JaxWsProxyFactoryBean創(chuàng)建client

    System.setProperty("http.proxySet", "true");
            System.setProperty("http.proxyHost", "IP");
            System.setProperty("http.proxyPort", "PORT");
            
            JaxWsProxyFactoryBean f = new JaxWsProxyFactoryBean();
            f.setAddress("THE URL OF WEBSERVICE");
            f.setServiceClass(IService.class);
            IService client = (IService) f.create();

    可以使用代理,但是用戶(hù)名密碼是不能像第一種方法中那樣設(shè)置到HttpConnection里面去的。

    又在網(wǎng)上找了很多資料,終于找到了一個(gè)配置的方法。

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xmlns:cxf="http://cxf.apache.org/core" 
            xmlns:sec="http://cxf.apache.org/configuration/security" 
            xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" 
            xsi:schemaLocation=" 
                    http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                    http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
                    http://cxf.apache.org/configuration/security
                    http://cxf.apache.org/schemas/configuration/security.xsd
                    http://cxf.apache.org/transports/http/configuration
                    http://cxf.apache.org/schemas/configuration/http-conf.xsd"> 
            <http-conf:conduit name="*.http-conduit"> 
                <http-conf:proxyAuthorization>
                
                        <!-- 用戶(hù)名 -->
                        <sec:UserName>***</sec:UserName>
                        <!-- 密碼 -->
                        <sec:Password>***</sec:Password>
                        
                 </http-conf:proxyAuthorization>
                <!--
                    ProxyServer IP                ProxyServerPort PORT
                    ProxyServerType: HTTP or SOCKS
                 -->
                <http-conf:client
                        ProxyServer="192.168.1.4" 
                        ProxyServerPort="808"
                        ProxyServerType="HTTP"
                        Connection="Keep-Alive" 
                        AllowChunking="false"
                        ConnectionTimeout="50000" 
                        ReceiveTimeout="120000"
                        /> 
        </http-conf:conduit> 
    
        <!-- Client   -->
        </beans>

    <http-conf:conduit name="*.http-conduit"> 這里的name為”*.http-conduit”時(shí),將會(huì)對(duì)所有的client類(lèi)啟用這個(gè)代理,如果要配置某個(gè)client類(lèi)使用代理,可以這么寫(xiě)

    <http-conf:conduit name="{http://widgets/widgetvendor.net}widgetSOAPPort.http-conduit>
        ...
      </http-conf:conduit>

    {}里面的內(nèi)容是webservice的wsdl的<wsdl:definitions name="serviceName" targetNamespace="{}之后.之前的內(nèi)容是

    <wsdl:port name="BasicHttpBinding_IService" binding="i0:BasicHttpBinding_IService">

    <soap:address location="the address" />

    </wsdl:port>

    的name屬性。

    上述wsdl對(duì)應(yīng)的配置是

    <http-conf:conduit name="{http://hafeyang.blogjava.net}BasicHttpBinding_IService.http-conduit> ... </http-conf:conduit>

    參考資料

    http://fusesource.com/docs/framework/2.2/bind_trans/HTTPConsumerConfig.html

    http://topic.csdn.net/u/20090331/09/f3ce02e0-29be-40cc-a534-9f2e5ac23f9e.html

    http://old.nabble.com/http:conduit-Proxy-td20462360.html

    http://mail-archives.apache.org/mod_mbox/servicemix-users/200807.mbox/<4885FCBB.5070506@gmail.com>

    posted on 2010-01-12 17:10 衡鋒 閱讀(2861) 評(píng)論(1)  編輯  收藏

    評(píng)論

    # re: Spring+CXF配置HTTP代理訪問(wèn)Internet 2011-01-30 11:15 張見(jiàn)

    好  回復(fù)  更多評(píng)論   


    只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 日韩视频在线免费观看| 亚洲精品乱码久久久久久久久久久久 | 国产成人AV片无码免费| 亚洲性一级理论片在线观看| 日韩成人在线免费视频| 中文字幕a∨在线乱码免费看| 亚洲黄色中文字幕| 国产又大又粗又硬又长免费| 免费在线中文日本| 亚洲欧洲无码一区二区三区| 曰韩亚洲av人人夜夜澡人人爽| 猫咪免费人成网站在线观看| 青青草国产免费国产是公开| 亚洲精品在线播放视频| 无码欧精品亚洲日韩一区夜夜嗨| 最近2018中文字幕免费视频| 色欲aⅴ亚洲情无码AV| 亚洲最大福利视频网站| 国产在线观看免费视频播放器| 无码精品国产一区二区三区免费| 亚洲AV成人片无码网站| 久久精品国产亚洲av水果派| 国产成人精品久久亚洲| 免费看又爽又黄禁片视频1000 | 免费看美女让人桶尿口| 在线观看肉片AV网站免费| 亚洲AV无码一区二区大桥未久| 亚洲av无码成h人动漫无遮挡 | 亚洲人成激情在线播放| 亚洲日韩精品一区二区三区无码| 我想看一级毛片免费的| 一级毛片不卡片免费观看| 一级A毛片免费观看久久精品| 久久精品国产亚洲AV蜜臀色欲| 国产亚洲精品a在线无码| 免费a级毛片18以上观看精品| 一色屋成人免费精品网站| 久久国产精品萌白酱免费| 一级毛片**免费看试看20分钟| 亚洲狠狠色丁香婷婷综合| 亚洲精品免费在线|