String authentication="username:password";//鐢ㄦ埛+”:”+瀵嗙爜 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鍒涘緩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();
鍙互浣跨敤浠g悊錛屼絾鏄敤鎴峰悕瀵嗙爜鏄笉鑳藉儚絎竴縐嶆柟娉曚腑閭f牱璁劇疆鍒癏ttpConnection閲岄潰鍘葷殑銆?/p>
鍙堝湪緗戜笂鎵句簡寰堝璧勬枡錛岀粓浜庢壘鍒頒簡涓涓厤緗殑鏂規(guī)硶銆?/p>
<?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> <!-- 鐢ㄦ埛鍚?--> <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"> 榪欓噷鐨刵ame涓?#8221;*.http-conduit”鏃訛紝灝嗕細瀵規(guī)墍鏈夌殑client綾誨惎鐢ㄨ繖涓唬鐞嗭紝濡傛灉瑕侀厤緗煇涓猚lient綾諱嬌鐢ㄤ唬鐞嗭紝鍙互榪欎箞鍐?
<http-conf:conduit name="{http://widgets/widgetvendor.net}widgetSOAPPort.http-conduit> ... </http-conf:conduit>
{}閲岄潰鐨勫唴瀹規(guī)槸webservice鐨剋sdl鐨?lt;wsdl:definitions name="serviceName" targetNamespace="
{}涔嬪悗.涔嬪墠鐨勫唴瀹規(guī)槸
…
<wsdl:port name="BasicHttpBinding_IService" binding="i0:BasicHttpBinding_IService">
<soap:address location="the address" />
</wsdl:port>
… 鐨刵ame灞炴с?/p>
涓婅堪wsdl瀵瑰簲鐨勯厤緗槸 <http-conf:conduit name="{http://hafeyang.blogjava.net}BasicHttpBinding_IService.http-conduit> ... </http-conf:conduit> 鍙傝冭祫鏂?/p>
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>
]]>