You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ni...@apache.org on 2006/10/20 08:49:21 UTC
svn commit: r466014 - in
/incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful:
client/Client.java client/CustomerJohnReq.xml server/CustomerAllResp.xml
server/CustomerJohnResp.xml server/RestSourcePayloadProvider.java
Author: ningjiang
Date: Thu Oct 19 23:49:20 2006
New Revision: 466014
URL: http://svn.apache.org/viewvc?view=rev&rev=466014
Log:
[JIRA CXF-133] Updated the restful demo
Modified:
incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/Client.java
incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/CustomerJohnReq.xml
incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerAllResp.xml
incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerJohnResp.xml
incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/RestSourcePayloadProvider.java
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=466014&r1=466013&r2=466014
==============================================================================
--- 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 Thu Oct 19 23:49:20 2006
@@ -22,7 +22,9 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
+import java.net.URI;
import java.net.URL;
+import java.util.Map;
import java.util.Properties;
import javax.xml.namespace.QName;
@@ -35,6 +37,8 @@
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
import org.w3c.dom.Document;
@@ -69,7 +73,7 @@
QName portName = new QName("http://apache.org/hello_world_xml_http/wrapped",
"RestProviderPort");
- Cutomerservice service = new Cutomerservice(wsdlURL, serviceName);
+ Cutomerservice cutomerservice = new Cutomerservice(wsdlURL, serviceName);
Client client = new Client();
InputStream is = client.getClass().getResourceAsStream("CustomerJohnReq.xml");
@@ -77,7 +81,7 @@
DOMSource reqMsg = new DOMSource(doc);
// Sent HTTP POST request to update customer info
- Dispatch<DOMSource> disp = service.createDispatch(portName, DOMSource.class, Service.Mode.PAYLOAD);
+ 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);
printSource(result);
@@ -98,6 +102,24 @@
source = new StreamSource(in);
printSource(source);
+ // Use Dispatch to send GET request to query customer info
+ endpointAddress =
+ "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();
+ }
+ 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.PATH_INFO, path);
+ System.out.println("Invoking Restful GET Request with query string ");
+ Source returnSource = dispatch.invoke(null);
+ printSource(returnSource);
System.exit(0);
}
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/CustomerJohnReq.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/CustomerJohnReq.xml?view=diff&rev=466014&r1=466013&r2=466014
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/CustomerJohnReq.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/client/CustomerJohnReq.xml Thu Oct 19 23:49:20 2006
@@ -1,21 +1,4 @@
-<!--
- 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.
--->
+<?xml version="1.0" encoding="utf-8" ?>
<tns:Customer xmlns:tns="http://apache.org/hello_world_soap_http/types">
<tns:id>123456</tns:id>
</tns:Customer>
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerAllResp.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerAllResp.xml?view=diff&rev=466014&r1=466013&r2=466014
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerAllResp.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerAllResp.xml Thu Oct 19 23:49:20 2006
@@ -1,22 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
-<!--
- 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.
--->
<Customers>
<Customer href="http://localhost/customerservice/customer?id=1234">
<id>1234</id>
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerJohnResp.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerJohnResp.xml?view=diff&rev=466014&r1=466013&r2=466014
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerJohnResp.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/CustomerJohnResp.xml Thu Oct 19 23:49:20 2006
@@ -1,22 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
-<!--
- 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.
--->
<Customer>
<name>John</name>
<id>123456</id>
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/RestSourcePayloadProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/RestSourcePayloadProvider.java?view=diff&rev=466014&r1=466013&r2=466014
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/RestSourcePayloadProvider.java (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/RestSourcePayloadProvider.java Thu Oct 19 23:49:20 2006
@@ -95,7 +95,7 @@
try {
factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(true);
+ //factory.setValidating(true);
builder = factory.newDocumentBuilder();
InputStream greetMeResponse = getClass().getResourceAsStream(fileName);