cxf-2.3.3.jar
geronimo-annotation_1.0_spec-1.1.1.jar
geronimo-jaxws_2.2_spec-1.0.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
geronimo-ws-metadata_2.0_spec-1.1.3.jar
jaxb-api-2.2.1.jar
jaxb-impl-2.2.1.1.jar
neethi-2.0.4.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.7.jar
wstx-asl-3.2.9.jar
slf4j-api-1.6.2.jar
以上jar是client端需要的最少jar,如果需要webservice端,则需要增加其他几个,我直接打了rar附件,可以下载(这个是针对jetty的,如果不用jetty,则没必要增加)
jetty-http-7.5.4.v20111024.jarjetty-io-7.5.4.v20111024.jarjetty-server-7.5.4.v20111024.jar
jetty-util-7.5.4.v20111024.jar
jetty-continuation-7.5.4.v20111024.jar
简单介绍一下cxf开发客户端和服务端的代码块
发布服务端代码:
- @WebService
- public interface ApprovalService {
- /**
- * 3.1.10. 审批结果回调接口
- * @param status
- * @return
- */
- @WebMethod
- String syncApprovalResult(@WebParam(name = "status") String status);
- }
实现类
- @WebService
- public class ApprovalServiceImpl implements ApprovalService{
- @WebMethod
- public String syncApprovalResult(String status) {
- System.out.println("************************************************");
- return null;
- }
- }
发布webservice
- @Service
- public class ApprovalPublish implements Serializable{
- @PostConstruct//此方法为我项目中spring容器启动自动发布而写的
- public void publishApprovalService(){
- this.publish(ApprovalService.class, new ApprovalServiceImpl());
- }
- private void publish(Class<?> clazz, Object implObj) {
- System.out.println("启动webservice【"+clazz.getSimpleName()+"】");
- // 创建WebService服务工厂
- JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
- // 注册WebService接口
- factory.setServiceClass(clazz);
- // 发布接口
- factory.setAddress("http://localhost:9000/e7cc/" + clazz.getSimpleName());
- factory.setServiceBean(implObj);
- // factory.getInInterceptors().add(new LoggingInInterceptor());
- // factory.getOutInterceptors().add(new LoggingOutInterceptor());
- // 创建WebService
- factory.create();
- }
- public static void main(String[] args) {
- new ApprovalPublish().publishApprovalService();
- }
- }
以上就可以发布一个webservice服务了,访问地址:http://localhost:9000/e7cc/ApprovalService?wsdl
客户端代码
- public static void main(String[] args) {
- JaxWsProxyFactoryBean factoryBean=new JaxWsProxyFactoryBean();
- factoryBean.getInInterceptors().add(new LoggingInInterceptor());
- factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
- factoryBean.setServiceClass(ProcessService.class);
- factoryBean.setAddress("http://localhost:9000/e7cc/ApprovalService?wsdl");
- ApprovalService approvalService=(ApprovalService) factoryBean.create();
- approvalService.syncApprovalResult("hello");
- }
以上为cxf发布和调用服务的代码,这个是通过java的代理类做的,还有一种通过spring-application.xml的配置文件区生成的,原理一样,以后有时间补上吧