Cxf3.x + spring 3.x( 4.x) + maven releases the webservice, cxf3.xmaven

Source: Internet
Author: User

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.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.