Theory with practice, only to talk about the theory that it became an armchair, with a HelloWorld demo can be more intuitive. Let's start with the explanation:
First to the official Apache network download apache-cxf-2.2.2, (now has a higher version 2.4) address: http://cxf.apache.org/
Create a new Java Project, import cxf common. Jar packages, CXF common jar packages are as follows:
1, Commons-logging-1.1.1.jar
2, Cxf-2.4.1.jar
3, Geronimo-activation_1.1_spec-1.1.jar
4, Geronimo-annotation_1.0_spec-1.1.1.jar
5, Geronimo-javamail_1.4_spec-1.7.1.jar
6, Geronimo-jaxws_2.2_spec-1.0.jar
7, Geronimo-servlet_3.0_spec-1.0.jar
8, Geronimo-stax-api_1.0_spec-1.0.1.jar
9, Geronimo-ws-metadata_2.0_spec-1.1.3.jar
10, Jettison-1.3.jar
11, Jetty-continuation-7.4.2.v20110526.jar
12, Jetty-http-7.4.2.v20110526.jar
13, Jetty-io-7.4.2.v20110526.jar
14, Jetty-server-7.4.2.v20110526.jar
15, Jetty-util-7.4.2.v20110526.jar
16, Neethi-3.0.0.jar
17, Saaj-api-1.3.jar
18, Saaj-impl-1.3.2.jar
19, Serializer-2.7.1.jar
CXF jar package required when combining spring
(
Spring-asm-3.0.5.release.jar
Spring-beans-3.0.5.release.jar
Spring-context-3.0.5.release.jar
Spring-core-3.0.5.release.jar
Spring-expression-3.0.5.release.jar
Spring-aop-3.0.5.release.jar
Spring-web-3.0.5.release.jar
)
20, Wsdl4j-1.6.2.jar
21, Xalan-2.7.1.jar
22, Xercesimpl.jar
23, Xml-resolver-1.2.jar
24, Xmlschema-core-2.0.jar
25, Jaxb-api-2.2.1.jar----webservices service side need to add
26, Jaxb-impl-2.2.1.1.jar----If the version in the JDK is consistent with that version, the WebServices server and the client do not need to add
(Note: Jaxb-api and Jaxb-impl will conflict with JDK (JDK version <2.0> lower), when using these two jar packages, 2.2 versions of Jar can be overwritten with JDK version)
How to overwrite the JDK version: Locate the jre\lib\endorsed folder under the JDK's installation directory (if the endorsed folder does not exist, you can create a new file), and place jaxb-api-2.2.1 and jaxb-impl-2.2.1.1 in this folder.
First step: Create a new WebService server interface and implementation class
1. Service-side interface [Java] view plain copy package com.ws.services; Import Javax.jws.WebService; @WebService public interface Ihelloservices {public String sayhellotoall (string[] userNames); Public string[] Gethellowords (); public string SayHello (string name); }
2. Service-side interface implementation class[Java] View plain copy package com.ws.services.impl; import javax.jws.webservice; import com.ws.services.ihelloservices; @WebService ( Endpointinterface= "Com.ws.services.IHelloServices") public class helloservicesimpl implements ihelloservices { public string[] gethellowords () { string[] words = {"Hello vicky.", "Hello,i ' M vicky.", "Hi,ivy and simon."}; return words; } public string sayhello (string name) { return "hello " +name+ " ! "; } public string sayhellotoall (string[] UserNames) { String hello = " hello "; for (int i=0;i< usernames.length;i++) { if (i !=usernames.length-1) hello += usernames[i]+ " and "; else hello += usernames[i]+ "&NBSP;."; } return hello; } }
3, create the WebServices server, and publish the service
[Java] View plain copy package com.test;