I also used CXF in my previous work, but I used the environment built by others. This time I built the environment again. There were also problems encountered in the process, and I also did a simple sorting out.
As for what CXF is used for, I don’t want to say too much. Everyone knows that this is an implementation tool of webService technology in our java programming. Let’s talk about why CXF is used to implement webService:
1. Java’s webService implementation itself is a very performance-consuming implementation (the conversion between xml and java objects on the server and client side consumes performance)
2. At present, the mainstream webService applications of java are mainly CXF and AXIS2;
3. Through the understanding of online channels, the current efficiency of CXF is at least 50% higher than that of AXIS2;
4. In addition, there is a webService tool metro which is more efficient CXF is 10% higher;
5. CXF implementation materials can be found on the Internet, a lot of materials, metro materials are relatively small;
6. CXF is very mature in java application implementation. Enterprises are more inclined to use such a mature solution;
For the above reasons, I choose CXF to implement webService.
Reference:
Java Web Services: CXF performance comparison-performance comparison between CXF and the latest version of Axis2 and Metro
http://www.ibm.com/developerworks/cn/java/j -jws14/
Achieve the publishing of webService application by way of annotation
1. Basic Environment
After creating a new java web project cxf, download the cxf toolkit. After decompressing CXF, put all the jar packages under the cxf toolkit lib under the lib of the project.
The cxf toolkit version used here is: apache-cxf-2.7.12
Download link:
http://www.apache.org/dyn/closer.cgi?path=/cxf/2.7. 12/apache-cxf-2.7.12.zip
2. Write service interface
See file HelloWorld.java
< div class="dp-highlighter bg_java" style="font-family:Consolas,'Courier New',Courier,mono,serif; width:936.531px; overflow-x:auto; overflow-y:hidden; padding-top: 1px; position:relative; line-height:26px; margin:18px 0px!important; background-color:rgb(231,229,220)">
- packagecom.hsy.server;
- importjava.util.List; /span>
- < /span>
- importjavax.jws.WebParam;
- importcom.hsy.pojo.User;
- @WebService span>
- publicinterfaceHelloWorld{< /li>
- String sayHi(@WebParam(name=“text”)String text) ;
- String sayHiToUser( User user);
- String[] SayHiToUserList(List
userList); - }
< li style="border-style:none none none solid; border-left-width:3px; border-left-color:rgb(108,226,108); list-style:decimal-leading-zero outside; line-height:18px; margin :0px!important; padding:0px 3px 0 px 10px!important; background-color:rgb(248,248,248)"> importjavax.jws.WebService;
< /ol>