日期:2014-05-17  浏览次数:21063 次

Apache CXF客户端编写

拥有远程服务的接口与相关的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
?

?

?