From 9f27df367f7c7f0bd56682eabce83fa0d6a121a1 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Date: Thu, 14 Jul 2016 20:38:34 +0700 Subject: [PATCH 1/4] Apache CXF with Spring --- apache-cxf/cxf-spring/pom.xml | 117 ++++++++++++++++++ .../com/baeldung/cxf/spring/Baeldung.java | 9 ++ .../com/baeldung/cxf/spring/BaeldungImpl.java | 17 +++ .../java/com/baeldung/cxf/spring/Student.java | 20 +++ .../src/main/resources/client-beans.xml | 10 ++ .../src/main/webapp/WEB-INF/cxf-servlet.xml | 7 ++ .../src/main/webapp/WEB-INF/web.xml | 14 +++ .../com/baeldung/cxf/spring/StudentTest.java | 32 +++++ apache-cxf/pom.xml | 79 ++++++------ 9 files changed, 266 insertions(+), 39 deletions(-) create mode 100644 apache-cxf/cxf-spring/pom.xml create mode 100644 apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/Baeldung.java create mode 100644 apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/BaeldungImpl.java create mode 100644 apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/Student.java create mode 100644 apache-cxf/cxf-spring/src/main/resources/client-beans.xml create mode 100644 apache-cxf/cxf-spring/src/main/webapp/WEB-INF/cxf-servlet.xml create mode 100644 apache-cxf/cxf-spring/src/main/webapp/WEB-INF/web.xml create mode 100644 apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentTest.java diff --git a/apache-cxf/cxf-spring/pom.xml b/apache-cxf/cxf-spring/pom.xml new file mode 100644 index 0000000000..02750dd790 --- /dev/null +++ b/apache-cxf/cxf-spring/pom.xml @@ -0,0 +1,117 @@ + + 4.0.0 + cxf-spring + war + + com.baeldung + apache-cxf + 0.0.1-SNAPSHOT + + + 3.1.6 + 4.3.1.RELEASE + 2.19.1 + + + + + maven-war-plugin + 2.6 + + src/main/webapp/WEB-INF/web.xml + + + + maven-surefire-plugin + ${surefire.version} + + + StudentTest.java + + + + + + + + integration + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.5.0 + + + jetty9x + embedded + + + + localhost + 8080 + + + + + + start-server + pre-integration-test + + start + + + + stop-server + post-integration-test + + stop + + + + + + maven-surefire-plugin + ${surefire.version} + + + integration-test + + test + + + + none + + + + + + + + + + + + org.apache.cxf + cxf-rt-frontend-jaxws + ${cxf.version} + + + org.apache.cxf + cxf-rt-transports-http-jetty + ${cxf.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-web + ${spring.version} + + + \ No newline at end of file diff --git a/apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/Baeldung.java b/apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/Baeldung.java new file mode 100644 index 0000000000..4f880e6ada --- /dev/null +++ b/apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/Baeldung.java @@ -0,0 +1,9 @@ +package com.baeldung.cxf.spring; + +import javax.jws.WebService; + +@WebService +public interface Baeldung { + String hello(String name); + String register(Student student); +} \ No newline at end of file diff --git a/apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/BaeldungImpl.java b/apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/BaeldungImpl.java new file mode 100644 index 0000000000..911ce7f876 --- /dev/null +++ b/apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/BaeldungImpl.java @@ -0,0 +1,17 @@ +package com.baeldung.cxf.spring; + +import javax.jws.WebService; + +@WebService(endpointInterface = "com.baeldung.cxf.spring.Baeldung") +public class BaeldungImpl implements Baeldung { + private int counter; + + public String hello(String name) { + return "Hello " + name + "!"; + } + + public String register(Student student) { + counter++; + return student.getName() + " is registered student number " + counter; + } +} \ No newline at end of file diff --git a/apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/Student.java b/apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/Student.java new file mode 100644 index 0000000000..eb58057eb6 --- /dev/null +++ b/apache-cxf/cxf-spring/src/main/java/com/baeldung/cxf/spring/Student.java @@ -0,0 +1,20 @@ +package com.baeldung.cxf.spring; + +public class Student { + private String name; + + Student() { + } + + public Student(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/apache-cxf/cxf-spring/src/main/resources/client-beans.xml b/apache-cxf/cxf-spring/src/main/resources/client-beans.xml new file mode 100644 index 0000000000..3f30562193 --- /dev/null +++ b/apache-cxf/cxf-spring/src/main/resources/client-beans.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/cxf-servlet.xml b/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/cxf-servlet.xml new file mode 100644 index 0000000000..7669d3f942 --- /dev/null +++ b/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/web.xml b/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..0d7687771b --- /dev/null +++ b/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,14 @@ + + + + cxf + org.apache.cxf.transport.servlet.CXFServlet + 1 + + + cxf + /services/* + + \ No newline at end of file diff --git a/apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentTest.java b/apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentTest.java new file mode 100644 index 0000000000..44a9d11687 --- /dev/null +++ b/apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentTest.java @@ -0,0 +1,32 @@ +package com.baeldung.cxf.spring; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class StudentTest { + private ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "client-beans.xml" }); + private Baeldung baeldungProxy; + + { + baeldungProxy = (Baeldung) context.getBean("client"); + } + + @Test + public void whenUsingHelloMethod_thenCorrect() { + String response = baeldungProxy.hello("John Doe"); + assertEquals("Hello John Doe!", response); + } + + @Test + public void whenUsingRegisterMethod_thenCorrect() { + Student student1 = new Student("Adam"); + Student student2 = new Student("Eve"); + String student1Response = baeldungProxy.register(student1); + String student2Response = baeldungProxy.register(student2); + + assertEquals("Adam is registered student number 1", student1Response); + assertEquals("Eve is registered student number 2", student2Response); + } +} \ No newline at end of file diff --git a/apache-cxf/pom.xml b/apache-cxf/pom.xml index 41ae75a1de..e86e4be5cd 100644 --- a/apache-cxf/pom.xml +++ b/apache-cxf/pom.xml @@ -1,40 +1,41 @@ - 4.0.0 - com.baeldung - apache-cxf - 0.0.1-SNAPSHOT - pom - - cxf-introduction - - - - junit - junit - 4.12 - test - - - - install - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - org.codehaus.mojo - exec-maven-plugin - 1.5.0 - - - - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + com.baeldung + apache-cxf + 0.0.1-SNAPSHOT + pom + + cxf-introduction + cxf-spring + + + + junit + junit + 4.12 + test + + + + install + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + + + \ No newline at end of file From 97ba59c59f3e6f75eb3d33733912cd07969713f3 Mon Sep 17 00:00:00 2001 From: Zeger Hendrikse Date: Fri, 15 Jul 2016 12:54:28 +0200 Subject: [PATCH 2/4] Replaced tabs by spaces --- apache-cxf/cxf-introduction/pom.xml | 88 +++++------ apache-cxf/cxf-spring/pom.xml | 232 ++++++++++++++-------------- apache-cxf/pom.xml | 80 +++++----- 3 files changed, 200 insertions(+), 200 deletions(-) diff --git a/apache-cxf/cxf-introduction/pom.xml b/apache-cxf/cxf-introduction/pom.xml index 27a2978956..232a4f0089 100644 --- a/apache-cxf/cxf-introduction/pom.xml +++ b/apache-cxf/cxf-introduction/pom.xml @@ -1,47 +1,47 @@ - 4.0.0 - cxf-introduction - - com.baeldung - apache-cxf - 0.0.1-SNAPSHOT - - - 3.1.6 - - - - - org.codehaus.mojo - exec-maven-plugin - - com.baeldung.cxf.introduction.Server - - - - maven-surefire-plugin - 2.19.1 - - - **/StudentTest.java - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - ${cxf.version} - - - org.apache.cxf - cxf-rt-transports-http-jetty - ${cxf.version} - - - \ No newline at end of file + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + cxf-introduction + + com.baeldung + apache-cxf + 0.0.1-SNAPSHOT + + + 3.1.6 + + + + + org.codehaus.mojo + exec-maven-plugin + + com.baeldung.cxf.introduction.Server + + + + maven-surefire-plugin + 2.19.1 + + + **/StudentTest.java + + + + + + + + org.apache.cxf + cxf-rt-frontend-jaxws + ${cxf.version} + + + org.apache.cxf + cxf-rt-transports-http-jetty + ${cxf.version} + + + diff --git a/apache-cxf/cxf-spring/pom.xml b/apache-cxf/cxf-spring/pom.xml index 02750dd790..431c35c51d 100644 --- a/apache-cxf/cxf-spring/pom.xml +++ b/apache-cxf/cxf-spring/pom.xml @@ -1,117 +1,117 @@ - 4.0.0 - cxf-spring - war - - com.baeldung - apache-cxf - 0.0.1-SNAPSHOT - - - 3.1.6 - 4.3.1.RELEASE - 2.19.1 - - - - - maven-war-plugin - 2.6 - - src/main/webapp/WEB-INF/web.xml - - - - maven-surefire-plugin - ${surefire.version} - - - StudentTest.java - - - - - - - - integration - - - - org.codehaus.cargo - cargo-maven2-plugin - 1.5.0 - - - jetty9x - embedded - - - - localhost - 8080 - - - - - - start-server - pre-integration-test - - start - - - - stop-server - post-integration-test - - stop - - - - - - maven-surefire-plugin - ${surefire.version} - - - integration-test - - test - - - - none - - - - - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - ${cxf.version} - - - org.apache.cxf - cxf-rt-transports-http-jetty - ${cxf.version} - - - org.springframework - spring-context - ${spring.version} - - - org.springframework - spring-web - ${spring.version} - - - \ No newline at end of file + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + cxf-spring + war + + com.baeldung + apache-cxf + 0.0.1-SNAPSHOT + + + 3.1.6 + 4.3.1.RELEASE + 2.19.1 + + + + + maven-war-plugin + 2.6 + + src/main/webapp/WEB-INF/web.xml + + + + maven-surefire-plugin + ${surefire.version} + + + StudentTest.java + + + + + + + + integration + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.5.0 + + + jetty9x + embedded + + + + localhost + 8080 + + + + + + start-server + pre-integration-test + + start + + + + stop-server + post-integration-test + + stop + + + + + + maven-surefire-plugin + ${surefire.version} + + + integration-test + + test + + + + none + + + + + + + + + + + + org.apache.cxf + cxf-rt-frontend-jaxws + ${cxf.version} + + + org.apache.cxf + cxf-rt-transports-http-jetty + ${cxf.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-web + ${spring.version} + + + diff --git a/apache-cxf/pom.xml b/apache-cxf/pom.xml index e86e4be5cd..022fc59f9b 100644 --- a/apache-cxf/pom.xml +++ b/apache-cxf/pom.xml @@ -1,41 +1,41 @@ - 4.0.0 - com.baeldung - apache-cxf - 0.0.1-SNAPSHOT - pom - - cxf-introduction - cxf-spring - - - - junit - junit - 4.12 - test - - - - install - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - org.codehaus.mojo - exec-maven-plugin - 1.5.0 - - - - - \ No newline at end of file + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + com.baeldung + apache-cxf + 0.0.1-SNAPSHOT + pom + + cxf-introduction + cxf-spring + + + + junit + junit + 4.12 + test + + + + install + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + + + From a7b1b46e6056533be800553ebe32242cb21d9cb3 Mon Sep 17 00:00:00 2001 From: Zeger Hendrikse Date: Fri, 15 Jul 2016 13:02:13 +0200 Subject: [PATCH 3/4] Replaced tabs by spaces --- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 10 ++++---- .../src/main/webapp/WEB-INF/web.xml | 24 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/cxf-servlet.xml b/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/cxf-servlet.xml index 7669d3f942..9fe87ba9ee 100644 --- a/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -1,7 +1,7 @@ - - \ No newline at end of file + 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"> + + diff --git a/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/web.xml b/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/web.xml index 0d7687771b..43a03b1d8b 100644 --- a/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/web.xml +++ b/apache-cxf/cxf-spring/src/main/webapp/WEB-INF/web.xml @@ -1,14 +1,14 @@ - - cxf - org.apache.cxf.transport.servlet.CXFServlet - 1 - - - cxf - /services/* - - \ No newline at end of file + version="3.0" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> + + cxf + org.apache.cxf.transport.servlet.CXFServlet + 1 + + + cxf + /services/* + + From ca889aec4174105efbb160f12a760544691f726e Mon Sep 17 00:00:00 2001 From: Zeger Hendrikse Date: Fri, 15 Jul 2016 13:08:52 +0200 Subject: [PATCH 4/4] Replaced tabs by spaces --- .../src/main/resources/client-beans.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apache-cxf/cxf-spring/src/main/resources/client-beans.xml b/apache-cxf/cxf-spring/src/main/resources/client-beans.xml index 3f30562193..626252b565 100644 --- a/apache-cxf/cxf-spring/src/main/resources/client-beans.xml +++ b/apache-cxf/cxf-spring/src/main/resources/client-beans.xml @@ -1,10 +1,10 @@ - - - - - - \ No newline at end of file + 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/schema/jaxws.xsd"> + + + + + +