在ssm中发布Apache CXF WebService

作用:两个异构系统,需要共享数据。

需求:我们要给客户提供合同追踪。在出口报运中增加一个WebService,用户可以通过它的系统来访问这个服务,展现出口报运单,主要可以浏览用户的订单状态(走到哪个流程),查看出口报运单。

 

开发步骤:将现有的Service改造成WebService

1)  将CXF整合到项目中,加入jar包。依赖jar。


	
		org.apache.cxf
		cxf-rt-frontend-jaxws
		3.0.0-milestone2
	
	
		org.apache.cxf
		cxf-rt-transports-http
		3.0.0-milestone2
	
	
	
		org.apache.cxf
		cxf-rt-transports-http-jetty
		3.0.0-milestone2

2)  改造现有的Service变成即支持Service原有的业务,还支持WebService,其中Export要实现Serializable接口

在ssm中发布Apache CXF WebService_第1张图片

3)  配置cxf.xml核心配置文件


    
    
    
    
    
    
    
		
		
	

其中配置Mapper映射文件扫描器是为了使用spring的mapper,如上图中的exportMapper

4)  发布WebService方法供客户的系统进行调用web.xml


  
  	cxf
  	org.apache.cxf.transport.servlet.CXFServlet
  	
  		config-location
  		classpath:cxf.xml
  	
  
  
  	cxf
  	/cxf/*
  

5)  模拟用户调用ajax;soap 发送xml;接收xml

使用Eclipse自带的WebService浏览器可以模拟soap 发送xml、接收xml

在ssm中发布Apache CXF WebService_第2张图片



你可能感兴趣的:(ssm)