Posted on 2010-02-26 13:56
月下孤城 阅读(758)
评论(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