Cxf3.x + spring 3.x( 4.x) + maven releases the webservice, cxf3.xmaven
Cxf is really useful when providing enterprise-level webservices. I personally think it is better than axis1 and 2. Although spring also provides the webservices release method, It is very convenient to use cxf in combination with spring;
The overall project result is as follows:
Maven-based configuration makes the project simpler
<?xml version="1.0" encoding="UTF-8"?> <!-- START SNIPPET: beans --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <jaxws:endpoint id="DepartmentService" implementor="com.qycloud.oatos.ty.department.DepartmentServiceImpl" address="/DepartmentService"/> <jaxws:endpoint id="UserService" implementor="com.qycloud.oatos.ty.user.UserServiceImpl" address="/UserService"/> </beans>
4. Complete pom. xml, mainly spring dependencies and cxf. cxf only requires the following two
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>3.0.0</version> </dependency>
A) Compile an Interface
'''Java @ WebService public interface DepartmentService {
Boolean updateTheOrg (String org );
Boolean updateOrgsCode (String org );
}'''
B) Compile an implementation class
'''Java @ WebService (endpointInterface = "com. qycloud. oatos. ty. department. DepartmentService") public class DepartmentServiceImpl implements DepartmentService {
@ Override public boolean updateTheOrg (String org) {// TODO Auto-generated method stub return false ;}
@ Override public boolean updateOrgsCode (String org) {// TODO Auto-generated method stub return false ;}
}'''
7. The rest is release. Right-click run on server. The result is as follows:
How to configure spring when the client of the CXF Framework calls the webservice released by AXIS
Through the wsdl2java tool of CXF, the java code is generated and called directly.
CXF integrates spring to implement webservice. This is included in the spring configuration file: (as follows) What are the configuration files?
Is the configuration file in the cxf-*. jar package that is reflected in the project, such as my cxf-2.4.2.jar/META-INF/cxf/cxf-servlet.xml and so on.