forked from apache/cxf
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from elans3/patch-1
Create jaxws_spring_boot Client
- Loading branch information
Showing
15 changed files
with
693 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
distribution/src/main/release/samples/jaxrs_spring_boot/README
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
== Spring Boot - Samples - CXF Rest Web Services | ||
|
||
This sample project demonstrates how to use http://projects.spring.io/spring-rs-cxf/[CXF Rest 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/services/helloservice/sayHello/Elan will now display the output in the browser | ||
like "Hello Elan, Welcome to CXF RS Spring Boot World!!!" |
129 changes: 129 additions & 0 deletions
129
distribution/src/main/release/samples/jaxrs_spring_boot/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?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> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-samples</artifactId> | ||
<version>1.3.0.BUILD-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>spring-boot-sample-rs-cxf</artifactId> | ||
<name>Spring Boot Web Services Sample</name> | ||
<description>Spring Boot CXF Restful Web Services Sample</description> | ||
<url>http://projects.spring.io/spring-boot/</url> | ||
<properties> | ||
<main.basedir>${basedir}/../..</main.basedir> | ||
<cxf.version>3.0.0</cxf.version> | ||
<spring.version>4.2.0.BUILD-SNAPSHOT</spring.version> | ||
<jackson.version>2.3.0</jackson.version> | ||
<jetty.version>8.1.5.v20120716</jetty.version> | ||
<java.version>1.7</java.version> | ||
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-beans</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-frontend-jaxrs</artifactId> | ||
<version>${cxf.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-transports-http</artifactId> | ||
<version>${cxf.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>${jackson.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>${jackson.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.jaxrs</groupId> | ||
<artifactId>jackson-jaxrs-json-provider</artifactId> | ||
<version>${jackson.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
<version>${jackson.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-bundle-jaxrs</artifactId> | ||
<version>2.7.14</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-server</artifactId> | ||
<version>${jetty.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-servlet</artifactId> | ||
<version>${jetty.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-webapp</artifactId> | ||
<version>${jetty.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-servlets</artifactId> | ||
<version>${jetty.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-rs-service-description</artifactId> | ||
<version>3.0.0-milestone1</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
|
||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
18 changes: 18 additions & 0 deletions
18
.../main/release/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package sample.rs.service; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("/sayHello") | ||
public class HelloService { | ||
|
||
@GET | ||
@Path("/{a}") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String sayHello(@PathParam("a") String a) { | ||
return "Hello "+a+", Welcome to CXF RS Spring Boot World!!!"; | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...se/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package sample.rs.service; | ||
import org.apache.cxf.Bus; | ||
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; | ||
import org.apache.cxf.transport.servlet.CXFServlet; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; | ||
import org.springframework.boot.context.embedded.ServletRegistrationBean; | ||
import org.springframework.boot.context.web.SpringBootServletInitializer; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.ImportResource; | ||
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; | ||
|
||
import org.apache.cxf.endpoint.Server; | ||
import org.apache.cxf.bus.spring.SpringBus; | ||
import sample.rs.service.HelloService; | ||
import org.apache.cxf.jaxrs.JAXRSBindingFactory; | ||
|
||
@Configuration | ||
@EnableAutoConfiguration | ||
@ImportResource({ "classpath:META-INF/cxf/cxf.xml" }) | ||
public class SampleRestWSApplication extends SpringBootServletInitializer { | ||
|
||
@Autowired | ||
private ApplicationContext applicationContext; | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SampleRestWSApplication.class, args); | ||
} | ||
|
||
@Bean | ||
public ServletRegistrationBean servletRegistrationBean(ApplicationContext context) { | ||
return new ServletRegistrationBean(new CXFServlet(), "/services/*"); | ||
} | ||
|
||
|
||
@Bean | ||
public Server rsServer() { | ||
Bus bus = (Bus) applicationContext.getBean(Bus.DEFAULT_BUS_ID); | ||
JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); | ||
endpoint.setServiceBean(new HelloService()); | ||
endpoint.setAddress("/helloservice"); | ||
endpoint.setBus(bus); | ||
return endpoint.create(); | ||
} | ||
|
||
@Override | ||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | ||
return application.sources(SampleRestWSApplication.class); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
distribution/src/main/release/samples/jaxws_spring_boot/README
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
== 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. | ||
|
||
to run the client navigate to the client folder. | ||
|
11 changes: 11 additions & 0 deletions
11
distribution/src/main/release/samples/jaxws_spring_boot/client/README_CLIENT.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
== Spring Boot - CXF Samples - Web Services Client | ||
|
||
This sample project demonstrates how to run the client CXF Web Services with Spring Boot. | ||
|
||
The sample uses Maven. It can be built and run from the command line: | ||
|
||
---- | ||
$ mvn exec:java | ||
---- | ||
|
||
Will display the execution result in the console. |
57 changes: 57 additions & 0 deletions
57
distribution/src/main/release/samples/jaxws_spring_boot/client/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?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> | ||
<artifactId>spring-boot-sample-ws-cxf-Client</artifactId> | ||
<name>Spring Boot CXF Web Services Sample Client</name> | ||
<description>Spring Boot CXF Web Services Sample Client</description> | ||
<groupId>org.apache.cxf.spring.boot</groupId> | ||
<version>1.0.0</version> | ||
<dependencies> | ||
<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> | ||
<version>1.2.3.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>jaxen</groupId> | ||
<artifactId>jaxen</artifactId> | ||
<version>1.1.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jdom</groupId> | ||
<artifactId>jdom2</artifactId> | ||
<version>2.0.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>wsdl4j</groupId> | ||
<artifactId>wsdl4j</artifactId> | ||
<version>1.6.3</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<configuration> | ||
<mainClass>sample.ws.service.client.HelloClient</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
43 changes: 43 additions & 0 deletions
43
.../main/release/samples/jaxws_spring_boot/client/src/main/java/sample/ws/service/Hello.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" , serviceName = "HelloService") | ||
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); | ||
} |
24 changes: 24 additions & 0 deletions
24
.../samples/jaxws_spring_boot/client/src/main/java/sample/ws/service/client/HelloClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package sample.ws.service.client; | ||
|
||
import java.net.URL; | ||
|
||
import javax.xml.namespace.QName; | ||
import javax.xml.ws.Service; | ||
|
||
import sample.ws.service.Hello; | ||
|
||
public class HelloClient { | ||
|
||
public static void main(String[] args) { | ||
try { | ||
URL wsdlURL = new URL("http://localhost:8080/Service/Hello?wsdl"); | ||
QName SERVICE_NAME = new QName("http://service.ws.sample/","HelloService"); | ||
Service service = Service.create(wsdlURL, SERVICE_NAME); | ||
Hello client = service.getPort(Hello.class); | ||
System.out.println(client.sayHello("Elan")); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.