Repository: cxf Updated Branches: refs/heads/master 6f3f4c1f8 -> ef8bec404
Springboot-CXF-Client Changes Created the client code for the CXF spring boot application. Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/34e083dd Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/34e083dd Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/34e083dd Branch: refs/heads/master Commit: 34e083dd1c4cccf4bda941dace30134dad546ab0 Parents: 4bdbdf6 Author: elans3 <[email protected]> Authored: Thu May 21 13:48:34 2015 -0500 Committer: elans3 <[email protected]> Committed: Thu May 21 13:48:34 2015 -0500 ---------------------------------------------------------------------- .../release/samples/jaxws_spring_boot/README | 3 ++ .../jaxws_spring_boot/client/README_CLIENT.txt | 11 ++++ .../samples/jaxws_spring_boot/client/pom.xml | 57 ++++++++++++++++++++ .../src/main/java/sample/ws/service/Hello.java | 43 +++++++++++++++ .../sample/ws/service/client/HelloClient.java | 24 +++++++++ 5 files changed, 138 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/34e083dd/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 index 595165d..748feb1 100644 --- a/distribution/src/main/release/samples/jaxws_spring_boot/README +++ b/distribution/src/main/release/samples/jaxws_spring_boot/README @@ -10,3 +10,6 @@ $ 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. + http://git-wip-us.apache.org/repos/asf/cxf/blob/34e083dd/distribution/src/main/release/samples/jaxws_spring_boot/client/README_CLIENT.txt ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/client/README_CLIENT.txt b/distribution/src/main/release/samples/jaxws_spring_boot/client/README_CLIENT.txt new file mode 100644 index 0000000..edd222f --- /dev/null +++ b/distribution/src/main/release/samples/jaxws_spring_boot/client/README_CLIENT.txt @@ -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. http://git-wip-us.apache.org/repos/asf/cxf/blob/34e083dd/distribution/src/main/release/samples/jaxws_spring_boot/client/pom.xml ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/client/pom.xml b/distribution/src/main/release/samples/jaxws_spring_boot/client/pom.xml new file mode 100644 index 0000000..a6ce361 --- /dev/null +++ b/distribution/src/main/release/samples/jaxws_spring_boot/client/pom.xml @@ -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> http://git-wip-us.apache.org/repos/asf/cxf/blob/34e083dd/distribution/src/main/release/samples/jaxws_spring_boot/client/src/main/java/sample/ws/service/Hello.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/client/src/main/java/sample/ws/service/Hello.java b/distribution/src/main/release/samples/jaxws_spring_boot/client/src/main/java/sample/ws/service/Hello.java new file mode 100644 index 0000000..1f48ffc --- /dev/null +++ b/distribution/src/main/release/samples/jaxws_spring_boot/client/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" , 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); +} http://git-wip-us.apache.org/repos/asf/cxf/blob/34e083dd/distribution/src/main/release/samples/jaxws_spring_boot/client/src/main/java/sample/ws/service/client/HelloClient.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/client/src/main/java/sample/ws/service/client/HelloClient.java b/distribution/src/main/release/samples/jaxws_spring_boot/client/src/main/java/sample/ws/service/client/HelloClient.java new file mode 100644 index 0000000..59ba104 --- /dev/null +++ b/distribution/src/main/release/samples/jaxws_spring_boot/client/src/main/java/sample/ws/service/client/HelloClient.java @@ -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(); + } + } + +}
