Posted on 2010-02-26 13:56
月下孤城 閱讀(765)
評論(0) 編輯 收藏

調用方法
1 /**
2 * 創建一個webservice代理對象
3 * @param address webService訪問地址
4 * @param serviceClass 接口服務類
5 * @param timeout ws連接失效時間
6 * @return
7 */
8 public static Object createWebServiceProxy(String address,Class serviceClass,long timeout){
9 JaxWsProxyFactoryBean soapFactoryBean = new JaxWsProxyFactoryBean();
10 // soapFactoryBean.setAddress("http://127.0.0.1:8080/helloService");
11 soapFactoryBean.setAddress(address);
12 soapFactoryBean.setServiceClass(serviceClass);
13
14 Object o = soapFactoryBean.create();
15
16 Client client = soapFactoryBean.getClientFactoryBean().getClient();
17 if(client != null){
18 HTTPConduit conduit = (HTTPConduit)client.getConduit();
19 HTTPClientPolicy policy = new HTTPClientPolicy();
20 policy.setConnectionTimeout(timeout);
21 policy.setReceiveTimeout(timeout);
22 conduit.setClient(policy);
23 }
24 return o;
25 }
該方法為客戶端ws調用方法,返回一個訪問ws接口服務對象(即傳入參數中的serviceClass接口對象)。
---------------------
月下孤城
mail:eagle_daiqiang@sina.com