cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Update jaxws_spring_boot sample client to make a call to the service and print result
Date Wed, 22 Mar 2017 16:35:58 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes d69a9c8cc -> b81dd0934


Update jaxws_spring_boot sample client to make a call to the service and print result


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

Branch: refs/heads/3.1.x-fixes
Commit: b81dd0934986a17a46da8efdd4d3faee02e1d82c
Parents: d69a9c8
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Mar 22 12:18:48 2017 -0400
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Mar 22 16:35:35 2017 +0000

----------------------------------------------------------------------
 .../sample/ws/SampleWsApplicationClient.java    | 32 ++++++++++++--------
 1 file changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b81dd093/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplicationClient.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplicationClient.java
b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplicationClient.java
index 15ea971..e234fd2 100644
--- a/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplicationClient.java
+++ b/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/SampleWsApplicationClient.java
@@ -19,30 +19,36 @@
 package sample.ws;
 
 import java.io.StringReader;
+import java.net.URL;
 
-import javax.xml.transform.stream.StreamResult;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+
+import org.apache.cxf.staxutils.StaxUtils;
 
 
 //CHECKSTYLE:OFF
 public class SampleWsApplicationClient {
- 
-    public static void main(String[] args) {
+
+    public static void main(String[] args) throws Exception {
         String address = "http://localhost:8080/Service/Hello";
-        // final String request =
-        // "<q0:sayHello xmlns:q0=\"http://service.ws.sample\">Elan</q0:sayHello>";
         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);
-
-        //assertThat(this.output.toString(),
-        //           containsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-        //                          + "<ns2:sayHelloResponse xmlns:ns2=\"http://service.ws.sample/\">"
-        //                          + "<return>Hello, Welcome to CXF Spring boot Elan!!!</return>"
-        //                          + "</ns2:sayHelloResponse>"));
+        Service service = Service.create(new URL(address + "?wsdl"), 
+                                         new QName("http://service.ws.sample/" , "HelloService"));
+        Dispatch<Source> disp = service.createDispatch(new QName("http://service.ws.sample/"
, "HelloPort"),
+                                                       Source.class, Mode.PAYLOAD);
+        
+        Source result = disp.invoke(source);
+        String resultAsString = StaxUtils.toString(result);
+        System.out.println(resultAsString);
+       
     }
-
 }
 //CHECKSTYLE:ON
 


Mime
View raw message