加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

cxf 调用webservice的方式

发布时间:2020-12-17 01:19:06 所属栏目:安全 来源:网络整理
导读:方式一:通过ClientProxyFactoryBean 调用 public static T T getService(String url,ClassT cls) { ? ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); ? factory.setServiceClass(cls); ? factory.setAddress(url); ? T service = (T) fac

方式一:通过ClientProxyFactoryBean 调用

public static <T> T getService(String url,Class<T> cls) {
? ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
? factory.setServiceClass(cls);
? factory.setAddress(url);
? T service = (T) factory.create();
? return service;
?}

方式二:通过JaxWsDynamicClientFactory 调用

JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient("http://192.168.1.102:12000/testService?wsdl");

Object[] objects = client.invoke("test","test args");

附:cxf-dosgi发布webservice时只需要增加以下配置:

Dictionary<String,String> props = new Hashtable<String,String>();
? props.put("service.exported.interfaces","*");
? props.put("service.exported.intents","SOAP");
? props.put("service.exported.configs","org.apache.cxf.ws");
? props.put("org.apache.cxf.ws.address","http://192.168.1.102:12000/testService?wsdl");

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读