ITeye博客

Apache CXF客户端编写

卡拉阿风 · 2011-07-14 16:09 · Java EE · 企业架构 · Markdown

拥有远程服务的接口与相关的DTO文件后(合作方给予或由WSDL生成),有两种方法编写客户端:

a) 使用在spring的applicationContext中定义: 

 

<jaxws:client id="infoWebService" serviceClass="com.iteye.examples.infos.ws.InfoWebService" address="http://localhost:8080/examples/ws/infoservice"></jaxws:client>

 

b)使用JAXWS的API动态创建:

 

JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
		proxyFactory.setAddress(address);
		proxyFactory.setServiceClass(InfoWebService.class);
		InfoWebService infoWebService = (InfoWebService) proxyFactory.create();

 

备注:address需要和jax-ws endpoint定义的address一样

例如使用了 http://localhost:8080/examples/ws/InfoService 字母大小写

服务器会报

warn [org.apache.cxf.transport.servlet.ServletController] - Can't find the request for http://localhost:8080/examples/ws/InfoService's Observer

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。