cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [2/4] cxf git commit: Spring boot Samples for CXF Web Services
Date Tue, 19 May 2015 16:26:48 GMT
Spring boot Samples for CXF Web Services

Simple Spring boot Sample for CXF Web Services


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/a3347f03
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a3347f03
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a3347f03

Branch: refs/heads/master
Commit: a3347f0378b49b6db6ca6ec274098f4b52fd17cd
Parents: 04960b3
Author: elans3 <elans3.java@gmail.com>
Authored: Mon May 18 22:57:51 2015 -0500
Committer: elans3 <elans3.java@gmail.com>
Committed: Mon May 18 22:57:51 2015 -0500

----------------------------------------------------------------------
 .../src/main/release/samples/jaxws_spring_boot  |  4 --
 .../release/samples/jaxws_spring_boot/README    | 12 ++++
 .../release/samples/jaxws_spring_boot/pom.xml   | 68 ++++++++++++++++++
 .../java/sample/ws/SampleWsApplication.java     | 31 +++++++++
 .../main/java/sample/ws/WebServiceConfig.java   | 62 +++++++++++++++++
 .../src/main/java/sample/ws/service/Hello.java  | 43 ++++++++++++
 .../java/sample/ws/service/HelloPortImpl.java   | 38 ++++++++++
 .../ws/service/SampleWsApplicationTests.java    | 73 ++++++++++++++++++++
 8 files changed, 327 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a3347f03/distribution/src/main/release/samples/jaxws_spring_boot
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot b/distribution/src/main/release/samples/jaxws_spring_boot
deleted file mode 100644
index af919ac..0000000
--- a/distribution/src/main/release/samples/jaxws_spring_boot
+++ /dev/null
@@ -1,4 +0,0 @@
-== Spring Boot - Samples - CXF Web Services 
-
-This sample project demonstrates how to use http://projects.spring.io/spring-ws-cxf/[CXF
Web Services]
-with Spring Boot. 
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/README b/distribution/src/main/release/samples/jaxws_spring_boot/README
new file mode 100644
index 0000000..595165d
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/README
@@ -0,0 +1,12 @@
+== Spring Boot - CXF Samples - Web Services
+
+This sample project demonstrates how to use http://projects.spring.io/spring-ws-cxf/[CXF
Web Services]
+with Spring Boot. 
+
+The sample uses Maven. It can be built and run from the command line:
+
+----
+$ mvn spring-boot:run
+----
+
+http://localhost:8080/Service/Hello?WSDL will now display the generated WSDL.
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/pom.xml b/distribution/src/main/release/samples/jaxws_spring_boot/pom.xml
new file mode 100644
index 0000000..b6e2193
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<!-- Your own application should inherit from spring-boot-starter-parent -->
+		<artifactId>spring-boot-samples</artifactId>
+		<groupId>org.springframework.boot</groupId>
+		<version>1.3.0.BUILD-SNAPSHOT</version>
+	</parent>
+	<artifactId>spring-boot-sample-ws-cxf</artifactId>
+	<name>Spring Boot CXF Web Services Sample</name>
+	<description>Spring Boot CXF Web Services Sample</description>
+	<url>http://projects.spring.io/spring-boot/</url>
+	<organization>
+		<name>Elan Thangamani</name>
+		<url>NA</url>
+	</organization>
+	<properties>
+		<main.basedir>${basedir}/../..</main.basedir>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-bundle</artifactId>
+			<version>3.0.0-milestone2</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.xml</groupId>
+			<artifactId>jaxws-api</artifactId>
+			<version>2.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.jetty</groupId>
+			<artifactId>jetty-webapp</artifactId>
+			<version>9.3.0.M2</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-ws</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>jaxen</groupId>
+			<artifactId>jaxen</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.jdom</groupId>
+			<artifactId>jdom2</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>wsdl4j</groupId>
+			<artifactId>wsdl4j</artifactId>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+</project>
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplication.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplication.java
new file mode 100644
index 0000000..f84f65d
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplication.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package sample.ws;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SampleWsApplication {
+
+	public static void main(String[] args) throws Exception {
+		SpringApplication.run(SampleWsApplication.class, args);
+	}
+	
+	
+
+}
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/WebServiceConfig.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/WebServiceConfig.java
new file mode 100644
index 0000000..12691a0
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/WebServiceConfig.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package sample.ws;
+
+import org.springframework.boot.context.embedded.ServletRegistrationBean;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.ws.config.annotation.EnableWs;
+import org.springframework.ws.config.annotation.WsConfigurerAdapter;
+import org.springframework.ws.transport.http.MessageDispatcherServlet;
+import org.apache.cxf.bus.spring.SpringBus;
+import sample.ws.service.Hello;
+import sample.ws.service.HelloPortImpl;
+import javax.xml.ws.Endpoint;
+import org.apache.cxf.transport.servlet.CXFServlet;
+import org.apache.cxf.jaxws.EndpointImpl
+;
+
+@EnableWs
+@Configuration
+public class WebServiceConfig extends WsConfigurerAdapter {
+
+	@Bean 
+	public ServletRegistrationBean dispatcherServlet() { 
+	    CXFServlet cxfServlet = new CXFServlet(); 
+	    return new ServletRegistrationBean(cxfServlet, "/Service/*"); 
+	} 
+
+	@Bean(name="cxf") 
+	public SpringBus springBus() { 
+	    return new SpringBus(); 
+	} 
+
+	@Bean 
+	public Hello myService() { 
+	    return new HelloPortImpl(); 
+	} 
+
+	@Bean 
+	public Endpoint endpoint() { 
+	    EndpointImpl endpoint = new EndpointImpl(springBus(), myService()); 
+	    endpoint.publish("/Hello"); 
+	    return endpoint; 
+	} 
+}
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/Hello.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/Hello.java
new file mode 100644
index 0000000..cd520cb
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/Hello.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2012-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package sample.ws.service;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+/**
+ * Examples code for spring boot with CXF services. 
+ * Hello is the interface for sayHello interface.
+ * 
+ * This class was generated by Apache CXF 3.1.0 2015-05-18T13:02:03.098-05:00
+ * Generated source version: 3.1.0
+ *  
+ */
+@WebService(targetNamespace = "http://service.ws.sample/", name = "Hello")
+public interface Hello {
+
+	@WebResult(name = "return", targetNamespace = "")
+	@RequestWrapper(localName = "sayHello", targetNamespace = "http://service.ws.sample/", className
= "sample.ws.service.SayHello")
+	@WebMethod(action = "urn:SayHello")
+	@ResponseWrapper(localName = "sayHelloResponse", targetNamespace = "http://service.ws.sample/",
className = "sample.ws.service.SayHelloResponse")
+	public java.lang.String sayHello(
+			@WebParam(name = "myname", targetNamespace = "") java.lang.String myname);
+}
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/HelloPortImpl.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/HelloPortImpl.java
new file mode 100644
index 0000000..cdea783
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/HelloPortImpl.java
@@ -0,0 +1,38 @@
+package sample.ws.service;
+
+import java.util.logging.Logger;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+/**
+ * Examples code for spring boot with CXF services. 
+ * HelloPortImpl is the implementation for Hello interface.
+ * 
+ * This class was generated by Apache CXF 3.1.0 2015-05-18T13:02:03.098-05:00
+ * Generated source version: 3.1.0
+ *  
+ */
+
+@javax.jws.WebService(serviceName = "HelloService", portName = "HelloPort", targetNamespace
= "http://service.ws.sample/", endpointInterface = "sample.ws.service.Hello")
+public class HelloPortImpl implements Hello {
+
+	private static final Logger LOG = Logger.getLogger(HelloPortImpl.class
+			.getName());
+
+	public java.lang.String sayHello(java.lang.String myname) {
+		LOG.info("Executing operation sayHello" + myname);
+		try {
+			return "Welcome to CXF Spring boot " + myname + "!!!";
+
+		} catch (java.lang.Exception ex) {
+			ex.printStackTrace();
+			throw new RuntimeException(ex);
+		}
+	}
+
+}
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/test/java/sample/ws/service/SampleWsApplicationTests.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/test/java/sample/ws/service/SampleWsApplicationTests.java
new file mode 100644
index 0000000..acb058a
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/test/java/sample/ws/service/SampleWsApplicationTests.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package sample.ws.service;
+
+import java.io.StringReader;
+
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.IntegrationTest;
+import org.springframework.boot.test.OutputCapture;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.ws.client.core.WebServiceTemplate;
+import sample.ws.SampleWsApplication;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertThat;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = SampleWsApplication.class)
+@WebAppConfiguration
+@IntegrationTest("server.port=0")
+public class SampleWsApplicationTests {
+
+	@Rule
+	public OutputCapture output = new OutputCapture();
+
+	private WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
+
+	@Value("${local.server.port}")
+	private int serverPort;
+
+	@Before
+	public void setUp() {
+		this.webServiceTemplate.setDefaultUri("http://localhost:" + this.serverPort
+				+ "/Service/Hello");
+	}
+
+	@Test
+	public void testHelloRequest() {
+		//final String request = "<q0:sayHello xmlns:q0=\"http://service.ws.sample\">Elan</q0:sayHello>";
+		final String request = "<q0:sayHello xmlns:q0=\"http://service.ws.sample/\"><myname>Elan</myname></q0:sayHello>";
+				
+
+		StreamSource source = new StreamSource(new StringReader(request));
+		StreamResult result = new StreamResult(System.out);
+
+		this.webServiceTemplate.sendSourceAndReceiveToResult(source, result);
+		assertThat(this.output.toString(), containsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns2:sayHelloResponse
xmlns:ns2=\"http://service.ws.sample/\"><return>Welcome to CXF Spring boot Elan!!!</return></ns2:sayHelloResponse>"));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/a3347f03/distribution/src/main/release/samples/jaxws_spring_boot/README
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/README b/distribution/src/main/release/samples/jaxws_spring_boot/README
new file mode 100644
index 0000000..595165d
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/README
@@ -0,0 +1,12 @@
+== Spring Boot - CXF Samples - Web Services
+
+This sample project demonstrates how to use http://projects.spring.io/spring-ws-cxf/[CXF
Web Services]
+with Spring Boot. 
+
+The sample uses Maven. It can be built and run from the command line:
+
+----
+$ mvn spring-boot:run
+----
+
+http://localhost:8080/Service/Hello?WSDL will now display the generated WSDL.

http://git-wip-us.apache.org/repos/asf/cxf/blob/a3347f03/distribution/src/main/release/samples/jaxws_spring_boot/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/pom.xml b/distribution/src/main/release/samples/jaxws_spring_boot/pom.xml
new file mode 100644
index 0000000..b6e2193
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<!-- Your own application should inherit from spring-boot-starter-parent -->
+		<artifactId>spring-boot-samples</artifactId>
+		<groupId>org.springframework.boot</groupId>
+		<version>1.3.0.BUILD-SNAPSHOT</version>
+	</parent>
+	<artifactId>spring-boot-sample-ws-cxf</artifactId>
+	<name>Spring Boot CXF Web Services Sample</name>
+	<description>Spring Boot CXF Web Services Sample</description>
+	<url>http://projects.spring.io/spring-boot/</url>
+	<organization>
+		<name>Elan Thangamani</name>
+		<url>NA</url>
+	</organization>
+	<properties>
+		<main.basedir>${basedir}/../..</main.basedir>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-bundle</artifactId>
+			<version>3.0.0-milestone2</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.xml</groupId>
+			<artifactId>jaxws-api</artifactId>
+			<version>2.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.jetty</groupId>
+			<artifactId>jetty-webapp</artifactId>
+			<version>9.3.0.M2</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-ws</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>jaxen</groupId>
+			<artifactId>jaxen</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.jdom</groupId>
+			<artifactId>jdom2</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>wsdl4j</groupId>
+			<artifactId>wsdl4j</artifactId>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/a3347f03/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplication.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplication.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplication.java
new file mode 100644
index 0000000..f84f65d
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplication.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package sample.ws;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SampleWsApplication {
+
+	public static void main(String[] args) throws Exception {
+		SpringApplication.run(SampleWsApplication.class, args);
+	}
+	
+	
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/a3347f03/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/WebServiceConfig.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/WebServiceConfig.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/WebServiceConfig.java
new file mode 100644
index 0000000..12691a0
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/WebServiceConfig.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package sample.ws;
+
+import org.springframework.boot.context.embedded.ServletRegistrationBean;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.ws.config.annotation.EnableWs;
+import org.springframework.ws.config.annotation.WsConfigurerAdapter;
+import org.springframework.ws.transport.http.MessageDispatcherServlet;
+import org.apache.cxf.bus.spring.SpringBus;
+import sample.ws.service.Hello;
+import sample.ws.service.HelloPortImpl;
+import javax.xml.ws.Endpoint;
+import org.apache.cxf.transport.servlet.CXFServlet;
+import org.apache.cxf.jaxws.EndpointImpl
+;
+
+@EnableWs
+@Configuration
+public class WebServiceConfig extends WsConfigurerAdapter {
+
+	@Bean 
+	public ServletRegistrationBean dispatcherServlet() { 
+	    CXFServlet cxfServlet = new CXFServlet(); 
+	    return new ServletRegistrationBean(cxfServlet, "/Service/*"); 
+	} 
+
+	@Bean(name="cxf") 
+	public SpringBus springBus() { 
+	    return new SpringBus(); 
+	} 
+
+	@Bean 
+	public Hello myService() { 
+	    return new HelloPortImpl(); 
+	} 
+
+	@Bean 
+	public Endpoint endpoint() { 
+	    EndpointImpl endpoint = new EndpointImpl(springBus(), myService()); 
+	    endpoint.publish("/Hello"); 
+	    return endpoint; 
+	} 
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/a3347f03/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/Hello.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/Hello.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/Hello.java
new file mode 100644
index 0000000..cd520cb
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/Hello.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2012-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package sample.ws.service;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+/**
+ * Examples code for spring boot with CXF services. 
+ * Hello is the interface for sayHello interface.
+ * 
+ * This class was generated by Apache CXF 3.1.0 2015-05-18T13:02:03.098-05:00
+ * Generated source version: 3.1.0
+ *  
+ */
+@WebService(targetNamespace = "http://service.ws.sample/", name = "Hello")
+public interface Hello {
+
+	@WebResult(name = "return", targetNamespace = "")
+	@RequestWrapper(localName = "sayHello", targetNamespace = "http://service.ws.sample/", className
= "sample.ws.service.SayHello")
+	@WebMethod(action = "urn:SayHello")
+	@ResponseWrapper(localName = "sayHelloResponse", targetNamespace = "http://service.ws.sample/",
className = "sample.ws.service.SayHelloResponse")
+	public java.lang.String sayHello(
+			@WebParam(name = "myname", targetNamespace = "") java.lang.String myname);
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/a3347f03/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/HelloPortImpl.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/HelloPortImpl.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/HelloPortImpl.java
new file mode 100644
index 0000000..cdea783
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/HelloPortImpl.java
@@ -0,0 +1,38 @@
+package sample.ws.service;
+
+import java.util.logging.Logger;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+/**
+ * Examples code for spring boot with CXF services. 
+ * HelloPortImpl is the implementation for Hello interface.
+ * 
+ * This class was generated by Apache CXF 3.1.0 2015-05-18T13:02:03.098-05:00
+ * Generated source version: 3.1.0
+ *  
+ */
+
+@javax.jws.WebService(serviceName = "HelloService", portName = "HelloPort", targetNamespace
= "http://service.ws.sample/", endpointInterface = "sample.ws.service.Hello")
+public class HelloPortImpl implements Hello {
+
+	private static final Logger LOG = Logger.getLogger(HelloPortImpl.class
+			.getName());
+
+	public java.lang.String sayHello(java.lang.String myname) {
+		LOG.info("Executing operation sayHello" + myname);
+		try {
+			return "Welcome to CXF Spring boot " + myname + "!!!";
+
+		} catch (java.lang.Exception ex) {
+			ex.printStackTrace();
+			throw new RuntimeException(ex);
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/a3347f03/distribution/src/main/release/samples/jaxws_spring_boot/src/test/java/sample/ws/service/SampleWsApplicationTests.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/test/java/sample/ws/service/SampleWsApplicationTests.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/test/java/sample/ws/service/SampleWsApplicationTests.java
new file mode 100644
index 0000000..acb058a
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/test/java/sample/ws/service/SampleWsApplicationTests.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package sample.ws.service;
+
+import java.io.StringReader;
+
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.IntegrationTest;
+import org.springframework.boot.test.OutputCapture;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.ws.client.core.WebServiceTemplate;
+import sample.ws.SampleWsApplication;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertThat;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = SampleWsApplication.class)
+@WebAppConfiguration
+@IntegrationTest("server.port=0")
+public class SampleWsApplicationTests {
+
+	@Rule
+	public OutputCapture output = new OutputCapture();
+
+	private WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
+
+	@Value("${local.server.port}")
+	private int serverPort;
+
+	@Before
+	public void setUp() {
+		this.webServiceTemplate.setDefaultUri("http://localhost:" + this.serverPort
+				+ "/Service/Hello");
+	}
+
+	@Test
+	public void testHelloRequest() {
+		//final String request = "<q0:sayHello xmlns:q0=\"http://service.ws.sample\">Elan</q0:sayHello>";
+		final String request = "<q0:sayHello xmlns:q0=\"http://service.ws.sample/\"><myname>Elan</myname></q0:sayHello>";
+				
+
+		StreamSource source = new StreamSource(new StringReader(request));
+		StreamResult result = new StreamResult(System.out);
+
+		this.webServiceTemplate.sendSourceAndReceiveToResult(source, result);
+		assertThat(this.output.toString(), containsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns2:sayHelloResponse
xmlns:ns2=\"http://service.ws.sample/\"><return>Welcome to CXF Spring boot Elan!!!</return></ns2:sayHelloResponse>"));
+	}
+
+}


Mime
View raw message