You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by mm...@apache.org on 2006/12/01 10:32:01 UTC
svn commit: r481199 - in
/incubator/cxf/trunk/distribution/src/main/release/samples: hello_world/
hello_world/src/demo/hw/client/ hello_world_RPCLit/
hello_world_RPCLit/src/demo/hwRPCLit/client/ hello_world_xml_bare/
hello_world_xml_bare/src/demo/hw/cl...
Author: mmao
Date: Fri Dec 1 01:31:56 2006
New Revision: 481199
URL: http://svn.apache.org/viewvc?view=rev&rev=481199
Log:
Add GET into all hello_world demos
Update REAMDE
Added:
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/src/demo/hw/client/Get.java (with props)
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/src/demo/hwRPCLit/client/Get.java (with props)
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/src/demo/hw/client/Get.java (with props)
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/src/demo/hw/client/Get.java (with props)
Modified:
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/README.txt
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/build.xml
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/README.txt
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/build.xml
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/README.txt
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/build.xml
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/README.txt
incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/build.xml
incubator/cxf/trunk/distribution/src/main/release/samples/soap12/README.txt
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/README.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/README.txt?view=diff&rev=481199&r1=481198&r2=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/README.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/README.txt Fri Dec 1 01:31:56 2006
@@ -154,4 +154,18 @@
Undeploy the application from the APACHE TOMCAT with the command:
- ant undeploy -Dtomcat=true
\ No newline at end of file
+ ant undeploy -Dtomcat=true
+
+
+Running demo with HTTP GET
+----------------------------------------------------
+APACHE CXF support HTTP GET to invoke the service, instead of running
+
+ ant client
+
+you can use
+
+ ant client.get
+
+to invoke the service with simple HttpURLConnection, or you can even
+use your favoriate browser to get the results back.
\ No newline at end of file
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/build.xml?view=diff&rev=481199&r1=481198&r2=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/build.xml Fri Dec 1 01:31:56 2006
@@ -33,6 +33,14 @@
<cxfrun classname="demo.hw.server.Server"
param1="${basedir}/wsdl/hello_world.wsdl"/>
</target>
+
+ <target name="client.get" description="run demo client through HTTP GET" depends="build">
+ <property name="param" value=""/>
+ <cxfrun classname="demo.hw.client.Get"
+ param1="${basedir}/wsdl/hello_world.wsdl"
+ param2="${op}"
+ param3="${param}"/>
+ </target>
<target name="generate.code">
<echo level="info" message="Generating code using wsdl2java..."/>
Added: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/src/demo/hw/client/Get.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/src/demo/hw/client/Get.java?view=auto&rev=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/src/demo/hw/client/Get.java (added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/src/demo/hw/client/Get.java Fri Dec 1 01:31:56 2006
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 demo.hw.client;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Properties;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+public final class Get {
+
+ private Get() {
+ }
+
+ public static void main(String args[]) throws Exception {
+ // Sent HTTP GET request to invoke sayHi
+ String target = "http://localhost:9000/SoapContext/SoapPort/sayHi";
+ URL url = new URL(target);
+ HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke sayHi");
+
+ InputStream in = httpConnection.getInputStream();
+ StreamSource source = new StreamSource(in);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke greetMe FAULT
+ target = "http://localhost:9000/SoapContext/SoapPort/greetMe/me/CXF";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke greetMe");
+
+ try {
+ in = httpConnection.getInputStream();
+ source = new StreamSource(in);
+ printSource(source);
+ } catch (Exception e) {
+ System.err.println("GreetMe Fault: " + e.getMessage());
+ }
+ InputStream err = httpConnection.getErrorStream();
+ source = new StreamSource(err);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke greetMe
+ target = "http://localhost:9000/SoapContext/SoapPort/greetMe/requestType/CXF";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke greetMe");
+
+ in = httpConnection.getInputStream();
+ source = new StreamSource(in);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke pingMe
+ target = "http://localhost:9000/SoapContext/SoapPort/pingMe";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke pingMe");
+
+ try {
+ in = httpConnection.getInputStream();
+ } catch (Exception e) {
+ System.out.println("PingMe fault raised");
+ }
+ err = httpConnection.getErrorStream();
+ source = new StreamSource(err);
+ printSource(source);
+ }
+
+ private static void printSource(Source source) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ StreamResult sr = new StreamResult(bos);
+ Transformer trans = TransformerFactory.newInstance().newTransformer();
+ Properties oprops = new Properties();
+ oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ trans.setOutputProperties(oprops);
+ trans.transform(source, sr);
+ System.out.println();
+ System.out.println("**** Response ******");
+ System.out.println();
+ System.out.println(bos.toString());
+ bos.close();
+ System.out.println();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/src/demo/hw/client/Get.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world/src/demo/hw/client/Get.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/README.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/README.txt?view=diff&rev=481199&r1=481198&r2=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/README.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/README.txt Fri Dec 1 01:31:56 2006
@@ -157,4 +157,18 @@
Undeploy the application from the APACHE TOMCAT with the command:
- ant undeploy -Dtomcat=true
\ No newline at end of file
+ ant undeploy -Dtomcat=true
+
+
+Running demo with HTTP GET
+----------------------------------------------------
+APACHE CXF support HTTP GET to invoke the service, instead of running
+
+ ant client
+
+you can use
+
+ ant client.get
+
+to invoke the service with simple HttpURLConnection, or you can even
+use your favoriate browser to get the results back.
\ No newline at end of file
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/build.xml?view=diff&rev=481199&r1=481198&r2=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/build.xml Fri Dec 1 01:31:56 2006
@@ -28,6 +28,14 @@
param2="${op}"
param3="${param}"/>
</target>
+
+ <target name="client.get" description="run demo client through HTTP GET" depends="build">
+ <property name="param" value=""/>
+ <cxfrun classname="demo.hwRPCLit.client.Get"
+ param1="${basedir}/wsdl/hello_world_RPCLit.wsdl"
+ param2="${op}"
+ param3="${param}"/>
+ </target>
<target name="server" description="run demo server" depends="build">
<cxfrun classname="demo.hwRPCLit.server.Server"
Added: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/src/demo/hwRPCLit/client/Get.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/src/demo/hwRPCLit/client/Get.java?view=auto&rev=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/src/demo/hwRPCLit/client/Get.java (added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/src/demo/hwRPCLit/client/Get.java Fri Dec 1 01:31:56 2006
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 demo.hwRPCLit.client;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Properties;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+public final class Get {
+
+ private Get() {
+ }
+
+ public static void main(String args[]) throws Exception {
+ // Sent HTTP GET request to invoke sayHi
+ String target = "http://localhost:9000/SoapContext/SoapPort/sayHi";
+ URL url = new URL(target);
+ HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke sayHi");
+
+ InputStream in = httpConnection.getInputStream();
+ StreamSource source = new StreamSource(in);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke greetMe FAULT
+ target = "http://localhost:9000/SoapContext/SoapPort/greetMe/me/CXF";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke greetMe");
+
+ try {
+ in = httpConnection.getInputStream();
+ source = new StreamSource(in);
+ printSource(source);
+ } catch (Exception e) {
+ System.err.println("GreetMe Fault: " + e.getMessage());
+ }
+ InputStream err = httpConnection.getErrorStream();
+ source = new StreamSource(err);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke greetMe
+ target = "http://localhost:9000/SoapContext/SoapPort/greetMe/in/CXF";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke greetMe");
+
+ in = httpConnection.getInputStream();
+ source = new StreamSource(in);
+ printSource(source);
+ }
+
+ private static void printSource(Source source) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ StreamResult sr = new StreamResult(bos);
+ Transformer trans = TransformerFactory.newInstance().newTransformer();
+ Properties oprops = new Properties();
+ oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ trans.setOutputProperties(oprops);
+ trans.transform(source, sr);
+ System.out.println();
+ System.out.println("**** Response ******");
+ System.out.println();
+ System.out.println(bos.toString());
+ bos.close();
+ System.out.println();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/src/demo/hwRPCLit/client/Get.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_RPCLit/src/demo/hwRPCLit/client/Get.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/README.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/README.txt?view=diff&rev=481199&r1=481198&r2=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/README.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/README.txt Fri Dec 1 01:31:56 2006
@@ -157,4 +157,18 @@
Undeploy the application from the APACHE TOMCAT with the command:
- ant undeploy -Dtomcat=true
\ No newline at end of file
+ ant undeploy -Dtomcat=true
+
+
+Running demo with HTTP GET
+----------------------------------------------------
+APACHE CXF support HTTP GET to invoke the service, instead of running
+
+ ant client
+
+you can use
+
+ ant client.get
+
+to invoke the service with simple HttpURLConnection, or you can even
+use your favoriate browser to get the results back.
\ No newline at end of file
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/build.xml?view=diff&rev=481199&r1=481198&r2=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/build.xml Fri Dec 1 01:31:56 2006
@@ -28,7 +28,15 @@
param2="${op}"
param3="${param}"/>
</target>
-
+
+ <target name="client.get" description="run demo client through HTTP GET" depends="build">
+ <property name="param" value=""/>
+ <cxfrun classname="demo.hw.client.Get"
+ param1="${basedir}/wsdl/hello_world.wsdl"
+ param2="${op}"
+ param3="${param}"/>
+ </target>
+
<target name="server" description="run demo server" depends="build">
<cxfrun classname="demo.hw.server.Server"
param1="${basedir}/wsdl/hello_world.wsdl"/>
Added: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/src/demo/hw/client/Get.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/src/demo/hw/client/Get.java?view=auto&rev=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/src/demo/hw/client/Get.java (added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/src/demo/hw/client/Get.java Fri Dec 1 01:31:56 2006
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 demo.hw.client;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Properties;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+public final class Get {
+
+ private Get() {
+ }
+
+ public static void main(String args[]) throws Exception {
+ // Sent HTTP GET request to invoke sayHi
+ String target = "http://localhost:9000/XMLService/XMLPort/sayHi";
+ URL url = new URL(target);
+ HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke sayHi");
+
+ InputStream in = httpConnection.getInputStream();
+ StreamSource source = new StreamSource(in);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke greetMe FAULT
+ target = "http://localhost:9000/XMLService/XMLPort/greetMe/me/CXF";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke greetMe");
+
+ try {
+ in = httpConnection.getInputStream();
+ source = new StreamSource(in);
+ printSource(source);
+ } catch (Exception e) {
+ System.err.println("GreetMe Fault: " + e.getMessage());
+ }
+ InputStream err = httpConnection.getErrorStream();
+ source = new StreamSource(err);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke greetMe
+ target = "http://localhost:9000/XMLService/XMLPort/greetMe/requestType/CXF";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke greetMe");
+
+ in = httpConnection.getInputStream();
+ source = new StreamSource(in);
+ printSource(source);
+ }
+
+ private static void printSource(Source source) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ StreamResult sr = new StreamResult(bos);
+ Transformer trans = TransformerFactory.newInstance().newTransformer();
+ Properties oprops = new Properties();
+ oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ trans.setOutputProperties(oprops);
+ trans.transform(source, sr);
+ System.out.println();
+ System.out.println("**** Response ******");
+ System.out.println();
+ System.out.println(bos.toString());
+ bos.close();
+ System.out.println();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/src/demo/hw/client/Get.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_bare/src/demo/hw/client/Get.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/README.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/README.txt?view=diff&rev=481199&r1=481198&r2=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/README.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/README.txt Fri Dec 1 01:31:56 2006
@@ -157,4 +157,18 @@
Undeploy the application from the APACHE TOMCAT with the command:
- ant undeploy -Dtomcat=true
\ No newline at end of file
+ ant undeploy -Dtomcat=true
+
+
+Running demo with HTTP GET
+----------------------------------------------------
+APACHE CXF support HTTP GET to invoke the service, instead of running
+
+ ant client
+
+you can use
+
+ ant client.get
+
+to invoke the service with simple HttpURLConnection, or you can even
+use your favoriate browser to get the results back.
\ No newline at end of file
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/build.xml?view=diff&rev=481199&r1=481198&r2=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/build.xml Fri Dec 1 01:31:56 2006
@@ -28,7 +28,15 @@
param2="${op}"
param3="${param}"/>
</target>
-
+
+ <target name="client.get" description="run demo client through HTTP GET" depends="build">
+ <property name="param" value=""/>
+ <cxfrun classname="demo.hw.client.Get"
+ param1="${basedir}/wsdl/hello_world.wsdl"
+ param2="${op}"
+ param3="${param}"/>
+ </target>
+
<target name="server" description="run demo server" depends="build">
<cxfrun classname="demo.hw.server.Server"
param1="${basedir}/wsdl/hello_world.wsdl"/>
Added: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/src/demo/hw/client/Get.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/src/demo/hw/client/Get.java?view=auto&rev=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/src/demo/hw/client/Get.java (added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/src/demo/hw/client/Get.java Fri Dec 1 01:31:56 2006
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 demo.hw.client;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Properties;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+public final class Get {
+
+ private Get() {
+ }
+
+ public static void main(String args[]) throws Exception {
+ // Sent HTTP GET request to invoke sayHi
+ String target = "http://localhost:9000/XMLService/XMLPort/sayHi";
+ URL url = new URL(target);
+ HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke sayHi");
+
+ InputStream in = httpConnection.getInputStream();
+ StreamSource source = new StreamSource(in);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke greetMe FAULT
+ target = "http://localhost:9000/XMLService/XMLPort/greetMe/me/CXF";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke greetMe");
+
+ try {
+ in = httpConnection.getInputStream();
+ source = new StreamSource(in);
+ printSource(source);
+ } catch (Exception e) {
+ System.err.println("GreetMe Fault: " + e.getMessage());
+ }
+ InputStream err = httpConnection.getErrorStream();
+ source = new StreamSource(err);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke greetMe
+ target = "http://localhost:9000/XMLService/XMLPort/greetMe/requestType/CXF";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke greetMe");
+
+ in = httpConnection.getInputStream();
+ source = new StreamSource(in);
+ printSource(source);
+
+ // Sent HTTP GET request to invoke pingMe
+ target = "http://localhost:9000/XMLService/XMLPort/pingMe";
+ url = new URL(target);
+ httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.connect();
+ System.out.println("Invoking server through HTTP GET to invoke pingMe");
+
+ try {
+ in = httpConnection.getInputStream();
+ } catch (Exception e) {
+ System.out.println("PingMe fault raised");
+ }
+ err = httpConnection.getErrorStream();
+ source = new StreamSource(err);
+ printSource(source);
+ }
+
+ private static void printSource(Source source) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ StreamResult sr = new StreamResult(bos);
+ Transformer trans = TransformerFactory.newInstance().newTransformer();
+ Properties oprops = new Properties();
+ oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ trans.setOutputProperties(oprops);
+ trans.transform(source, sr);
+ System.out.println();
+ System.out.println("**** Response ******");
+ System.out.println();
+ System.out.println(bos.toString());
+ bos.close();
+ System.out.println();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/src/demo/hw/client/Get.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/hello_world_xml_wrapped/src/demo/hw/client/Get.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/soap12/README.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/soap12/README.txt?view=diff&rev=481199&r1=481198&r2=481199
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/soap12/README.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/soap12/README.txt Fri Dec 1 01:31:56 2006
@@ -157,3 +157,17 @@
Undeploy the application from the APACHE TOMCAT with the command:
ant undeploy -Dtomcat=true
+
+
+Running demo with HTTP GET
+----------------------------------------------------
+APACHE CXF support HTTP GET to invoke the service, instead of running
+
+ ant client
+
+you can use
+
+ ant client.get
+
+to invoke the service with simple HttpURLConnection, or you can even
+use your favoriate browser to get the results back.
\ No newline at end of file