You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by jl...@apache.org on 2006/11/20 08:50:57 UTC
svn commit: r477093 - in
/incubator/cxf/trunk/distribution/src/main/release/samples/restful:
README.txt build.xml src/demo/restful/client/Client.java
Author: jliu
Date: Sun Nov 19 23:50:55 2006
New Revision: 477093
URL: http://svn.apache.org/viewvc?view=rev&rev=477093
Log:
Update restful demo's README.
Modified:
incubator/cxf/trunk/distribution/src/main/release/samples/restful/README.txt
incubator/cxf/trunk/distribution/src/main/release/samples/restful/build.xml
incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/Client.java
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/restful/README.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/restful/README.txt?view=diff&rev=477093&r1=477092&r2=477093
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/README.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/README.txt Sun Nov 19 23:50:55 2006
@@ -4,10 +4,10 @@
The demo shows REST based Web services using the XML binding and
JAX-WS Provider/Dispatch. The REST server provides the following services:
-A RESTful customer service is provided on URL http://localhost:9000/customerservice/customers.
+A RESTful customer service is provided on URL http://localhost:9000/customerservice/customer.
Users access this URI to query or update customer info.
-A HTTP GET request to URL http://localhost:9000/customerservice/customers returns
+A HTTP GET request to URL http://localhost:9000/customerservice/customer returns
a list of customer hyperlinks. This allows client navigates through the
application states. The returned XML document:
@@ -23,8 +23,8 @@
</Customer>
</Customers>
-A HTTP GET request to URL http://localhost:9000/customerservice/customers?id=1234
-returns a customer instance whose id is 1234. The returned XML document returned:
+A HTTP GET request to URL http://localhost:9000/customerservice/customer?id=1234
+returns a customer instance whose id is 1234. The returned XML document:
<Customer>
<id>1234</id>
@@ -32,7 +32,7 @@
<phoneNumber>123456</phoneNumber>
</Customer>
-A HTTP POST request to URL http://localhost:9000/customerservice/customers
+A HTTP POST request to URL http://localhost:9000/customerservice/customer
with the data:
<Customer>
@@ -93,13 +93,13 @@
For UNIX:
mkdir -p build/classes
- wsdl2java -d build/classes -compile ./wsdl/hello_world.wsdl
+ wsdl2java -d build/classes -compile ./wsdl/hello_world_xml_wrapped.wsdl
For Windows:
mkdir build\classes
Must use back slashes.
- wsdl2java -d build\classes -compile .\wsdl\hello_world.wsdl
+ wsdl2java -d build\classes -compile .\wsdl\hello_world_xml_wrapped.wsdl
May use either forward or back slashes.
Now compile the provided client and server applications with the commands:
@@ -107,28 +107,39 @@
For UNIX:
export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-incubator.jar:./build/classes
- javac -d build/classes src/demo/hw/client/*.java
- javac -d build/classes src/demo/hw/server/*.java
+ javac -d build/classes src/demo/restful/client/*.java
+ javac -d build/classes src/demo/restful/server/*.java
For Windows:
set classpath=%classpath%;%CXF_HOME%\lib\cxf-incubator.jar;.\build\classes
- javac -d build\classes src\demo\hw\client\*.java
- javac -d build\classes src\demo\hw\server\*.java
+ javac -d build\classes src\demo\restful\client\*.java
+ javac -d build\classes src\demo\restful\server\*.java
+Next copy resource files to build/classes directory with the commands:
+
+For UNIX:
+
+ cp src/demo/restful/client/*.xml build/classes/demo/restful/client
+ cp src/demo/restful/server/*.xml build/classes/demo/restful/server
+
+For Windows:
+ copy src\demo\restful\client\*.xml build\classes\demo\restful\client
+ copy src\demo\restful\server\*.xml build\classes\demo\restful\server
+
Running the demo using java
---------------------------
-From the samples/hello_world directory run the following commands. They
+From the samples/restful directory run the following commands. They
are entered on a single command line.
For UNIX (must use forward slashes):
java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties
- demo.hw.server.Server &
+ demo.restful.server.Server &
java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties
- demo.hw.client.Client ./wsdl/hello_world.wsdl
+ demo.restful.client.Client ./wsdl/hello_world_xml_wrapped.wsdl
The server process starts in the background. After running the client,
use the kill command to terminate the server process.
@@ -136,10 +147,10 @@
For Windows (may use either forward or back slashes):
start
java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties
- demo.hw.server.Server
+ demo.restful.server.Server
java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties
- demo.hw.client.Client .\wsdl\hello_world.wsdl
+ demo.restful.client.Client .\wsdl\hello_world_xml_wrapped.wsdl
A new command windows opens for the server process. After running the
client, terminate the server process by issuing Ctrl-C in its command window.
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/restful/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/restful/build.xml?view=diff&rev=477093&r1=477092&r2=477093
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/build.xml Sun Nov 19 23:50:55 2006
@@ -22,16 +22,12 @@
<import file="../common_build.xml"/>
<target name="client" description="run demo client" depends="build">
- <property name="param" value=""/>
<cxfrun classname="demo.restful.client.Client"
- param1="${basedir}/wsdl/hello_world_xml_wrapped.wsdl"
- param2="${op}"
- param3="${param}"/>
+ param1="${basedir}/wsdl/hello_world_xml_wrapped.wsdl"/>
</target>
<target name="server" description="run demo server" depends="build">
- <cxfrun classname="demo.restful.server.Server"
- param1="${basedir}/wsdl/hello_world_xml_wrapped.wsdl"/>
+ <cxfrun classname="demo.restful.server.Server"/>
</target>
<target name="generate.code">
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/Client.java?view=diff&rev=477093&r1=477092&r2=477093
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/Client.java (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/Client.java Sun Nov 19 23:50:55 2006
@@ -81,7 +81,7 @@
DOMSource reqMsg = new DOMSource(doc);
// Sent HTTP POST request to update customer info
- Dispatch<DOMSource> disp = cutomerservice.createDispatch(portName, DOMSource.class,
+ Dispatch<DOMSource> disp = cutomerservice.createDispatch(portName, DOMSource.class,
Service.Mode.PAYLOAD);
System.out.println("Invoking server through HTTP POST to update customer info");
DOMSource result = disp.invoke(reqMsg);
@@ -105,18 +105,18 @@
// Use Dispatch to send GET request to query customer info
endpointAddress =
- "http://localhost:9000/customerservice/customer";
- Service service = Service.create(serviceName);
+ "http://localhost:9000/customerservice/customer";
+ Service service = Service.create(serviceName);
URI endpointURI = new URI(endpointAddress.toString());
- String path = null;
- if (endpointURI != null) {
- path = endpointURI.getPath();
- }
+ String path = null;
+ if (endpointURI != null) {
+ path = endpointURI.getPath();
+ }
service.addPort(portName, HTTPBinding.HTTP_BINDING, endpointAddress.toString());
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
Map<String, Object> requestContext = dispatch.getRequestContext();
requestContext.put(MessageContext.HTTP_REQUEST_METHOD, new String("GET"));
- requestContext.put(MessageContext.QUERY_STRING, "id=1");
+ requestContext.put(MessageContext.QUERY_STRING, "id=1234");
requestContext.put(MessageContext.PATH_INFO, path);
System.out.println("Invoking Restful GET Request with query string ");
Source returnSource = dispatch.invoke(null);