cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r486085 - in /incubator/cxf/trunk: distribution/src/main/release/samples/ distribution/src/main/release/samples/restful/ distribution/src/main/release/samples/restful/src/demo/restful/server/ distribution/src/main/release/samples/restful/ws...
Date Tue, 12 Dec 2006 10:23:18 GMT
Author: jliu
Date: Tue Dec 12 02:23:17 2006
New Revision: 486085

URL: http://svn.apache.org/viewvc?view=rev&rev=486085
Log:
Update restful sample to use HTTP binding instead of XML binding, removes the presence of
wsdl file from sample's server side code. 

Removed:
    incubator/cxf/trunk/distribution/src/main/release/samples/restful/wsdl/
Modified:
    incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml
    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/server/RestSourcePayloadProvider.java
    incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/Server.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/HttpBindingServer.java
  (contents, props changed)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerHttpBindingTest.java
  (contents, props changed)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProviderHttpBinding.java
  (contents, props changed)

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml?view=diff&rev=486085&r1=486084&r2=486085
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml Tue Dec 12
02:23:17 2006
@@ -37,8 +37,8 @@
     <property name="srcbuild.classpath" value=""/>
 
     <uptodate property="codegen.notrequired" value="true">
-        <srcfiles dir="${wsdl.dir}" includes="**/*.wsdl"/>
-        <srcfiles dir="${wsdl.dir}" includes="**/*.xsd"/>
+        <srcfiles dir="${basedir}" includes="wsdl/**/*.wsdl"/>
+        <srcfiles dir="${basedir}" includes="wsdl/**/*.xsd"/>
         <mapper type="merge" to="${codegen.timestamp.file}"/>
     </uptodate>
 
@@ -89,6 +89,9 @@
     </target>
 
     <target name="compile" depends="maybe.generate.code">
+            <mkdir dir="${build.classes.dir}"/>
+            <mkdir dir="${build.src.dir}"/>
+
         <javac destdir="${build.classes.dir}" debug="true">
             <src path="${build.src.dir}"/>
             <src path="${basedir}/src"/>

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=486085&r1=486084&r2=486085
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/README.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/README.txt Tue Dec 12
02:23:17 2006
@@ -1,7 +1,7 @@
 RESTful Hello World Demo 
 ========================
 
-The demo shows REST based Web Services using the XML binding and 
+The demo shows REST based Web Services using the HTTP 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/customer.

@@ -90,29 +90,20 @@
 -------------------------------------------
 
 From the samples/restful directory, first create the target
-directory build/classes and then generate code from the WSDL file.
-
-For UNIX:
-  mkdir -p build/classes
-
-  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_xml_wrapped.wsdl
-    May use either forward or back slashes.
-
-Now compile the provided client and server applications with the commands:
+directory build/classes and then compile the provided client 
+and server applications with the commands:
 
 For UNIX:  
+  mkdir -p build/classes
   
   export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-incubator.jar:./build/classes
   javac -d build/classes src/demo/restful/client/*.java
   javac -d build/classes src/demo/restful/server/*.java
 
 For Windows:
+  mkdir build\classes
+    Must use back slashes.
+
   set classpath=%classpath%;%CXF_HOME%\lib\cxf-incubator.jar;.\build\classes
   javac -d build\classes src\demo\restful\client\*.java
   javac -d build\classes src\demo\restful\server\*.java

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=486085&r1=486084&r2=486085
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/build.xml Tue Dec 12
02:23:17 2006
@@ -18,6 +18,7 @@
   under the License.
 -->
 <project name="RESTful demo" default="build" basedir=".">
+    <property name="codegen.notrequired" value="true"/>
 
     <import file="../common_build.xml"/>        
         
@@ -27,11 +28,6 @@
         
     <target name="server" description="run demo server" depends="build">
         <cxfrun classname="demo.restful.server.Server"/>
-    </target>
-        
-    <target name="generate.code">
-        <echo level="info" message="Generating code using wsdl2java..."/>
-        <wsdl2java file="hello_world_xml_wrapped.wsdl"/>
     </target>
 
 </project>

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=486085&r1=486084&r2=486085
==============================================================================
--- 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
Tue Dec 12 02:23:17 2006
@@ -38,7 +38,6 @@
 
 @WebServiceProvider()
 @ServiceMode(value = Service.Mode.PAYLOAD)
-@javax.xml.ws.BindingType(value = "http://cxf.apache.org/bindings/xformat")
 public class RestSourcePayloadProvider implements Provider<DOMSource> {
 
     @Resource

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/Server.java?view=diff&rev=486085&r1=486084&r2=486085
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/Server.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/restful/src/demo/restful/server/Server.java
Tue Dec 12 02:23:17 2006
@@ -20,14 +20,15 @@
 package demo.restful.server;
 
 import javax.xml.ws.Endpoint;
+import javax.xml.ws.http.HTTPBinding;
 
 public class Server {
 
     protected Server() throws Exception {
         System.out.println("Starting Server");
-        Object implementor = new RestSourcePayloadProvider();
+        Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new RestSourcePayloadProvider());
         String address = "http://localhost:9000/customerservice/customer";
-        Endpoint.publish(address, implementor);
+        e.publish(address);
     }
 
     public static void main(String args[]) throws Exception {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/HttpBindingServer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/HttpBindingServer.java?view=diff&rev=486085&r1=486084&r2=486085
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/HttpBindingServer.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/HttpBindingServer.java
Tue Dec 12 02:23:17 2006
@@ -1,46 +1,46 @@
-/**
- * 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 org.apache.cxf.systest.rest;
-
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.http.HTTPBinding;
-
-import org.apache.cxf.systest.common.TestServerBase;
-
-public class HttpBindingServer extends TestServerBase {
-
-    protected void run() {
-        Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new RestSourcePayloadProviderHttpBinding());
-        String address = "http://localhost:9024/XMLService/RestProviderPort/Customer";
-        e.publish(address);
-    }        
-
-    public static void main(String[] args) {
-        try {
-            HttpBindingServer s = new HttpBindingServer();
-            s.start();
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            System.exit(-1);
-        } finally {
-            System.out.println("done!");
-        }
-    }    
-}
+/**
+ * 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 org.apache.cxf.systest.rest;
+
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.http.HTTPBinding;
+
+import org.apache.cxf.systest.common.TestServerBase;
+
+public class HttpBindingServer extends TestServerBase {
+
+    protected void run() {
+        Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new RestSourcePayloadProviderHttpBinding());
+        String address = "http://localhost:9024/XMLService/RestProviderPort/Customer";
+        e.publish(address);
+    }        
+
+    public static void main(String[] args) {
+        try {
+            HttpBindingServer s = new HttpBindingServer();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }    
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/HttpBindingServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/HttpBindingServer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerHttpBindingTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerHttpBindingTest.java?view=diff&rev=486085&r1=486084&r2=486085
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerHttpBindingTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerHttpBindingTest.java
Tue Dec 12 02:23:17 2006
@@ -1,131 +1,131 @@
-/**
- * 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 org.apache.cxf.systest.rest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.namespace.QName;
-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;
-import javax.xml.ws.Dispatch;
-
-import javax.xml.ws.Service;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.http.HTTPBinding;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.cxf.systest.common.ClientServerSetupBase;
-import org.apache.cxf.systest.common.ClientServerTestBase;
-
-public class RestClientServerHttpBindingTest extends ClientServerTestBase {
-    private final QName serviceName = new QName("http://apache.org/hello_world_xml_http/wrapped",
-                                                "XMLService");
-
-    private final QName portName = new QName("http://apache.org/hello_world_xml_http/wrapped",
-                                             "RestProviderPort");
-
-    private final String endpointAddress =
-        "http://localhost:9024/XMLService/RestProviderPort/Customer"; 
-   
-    public static Test suite() throws Exception {
-        TestSuite suite = new TestSuite(RestClientServerHttpBindingTest.class);
-        return new ClientServerSetupBase(suite) {
-            public void startServers() throws Exception {
-                assertTrue("server did not launch correctly", launchServer(HttpBindingServer.class));
-            }
-        };
-    }    
-   
-    public void testHttpGET() throws Exception {
-        URL url = new URL(endpointAddress + "?name=john&address=20");
-        InputStream in = url.openStream();
-        assertNotNull(in);       
-    }
-
-    public void testHttpPOSTDispatchHTTPBinding() throws Exception {
-        Service service = Service.create(serviceName);
-        service.addPort(portName, HTTPBinding.HTTP_BINDING, endpointAddress);
-        Dispatch<Source> dispatcher = service.createDispatch(portName, Source.class,
Service.Mode.MESSAGE);
-        Map<String, Object> requestContext = dispatcher.getRequestContext();
-        requestContext.put(MessageContext.HTTP_REQUEST_METHOD, "POST");
-        InputStream is = getClass().getResourceAsStream("resources/CustomerJohnReq.xml");
-        Source result = dispatcher.invoke(new StreamSource(is));
-        String tempstring = source2String(result);
-        assertTrue("Result should start with Customer", tempstring.startsWith("<ns4:Customer"));
-        assertTrue("Result should have CustomerID", tempstring.lastIndexOf("CustomerID>123456<")
> 0);
-    }
-    
-    @SuppressWarnings("unchecked")
-    public void testHttpGETDispatchHTTPBinding() throws Exception { 
-        Service service = Service.create(serviceName); 
-        URI endpointURI = new URI(endpointAddress);
-        String path = null; 
-        if (endpointURI != null) { 
-            path = endpointURI.getPath(); 
-        } 
-        service.addPort(portName, HTTPBinding.HTTP_BINDING, endpointAddress);
-        Dispatch<Source> d = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
-        Map<String, Object> requestContext = d.getRequestContext();
-        Map<String, Object> responseContext = d.getResponseContext();
-        
-        requestContext.put(MessageContext.HTTP_REQUEST_METHOD, "GET");
-        requestContext.put(MessageContext.QUERY_STRING, "id=1"); 
-        //this is the original path part of uri 
-        requestContext.put(MessageContext.PATH_INFO, path);        
-        Source result = d.invoke(null);
-        
-        // varify the responseContext;
-        Map<String, List<String>> responseHeader =
-            (Map<String, List<String>>)responseContext.get(MessageContext.HTTP_RESPONSE_HEADERS);
-        assertNotNull("the response header should not be null", responseHeader);
-        
-        List<String> values = responseHeader.get("REST");
-        assertNotNull("the response rest header should not be null", values);
-        assertEquals("the list size wrong", 2, values.size());        
-        assertNotNull("result shoud not be null", result);        
-        String tempstring = source2String(result);
-        assertTrue("Result should start with Customer", tempstring.startsWith("<ns4:Customer"));
-        assertTrue("Result should have CustomerID", tempstring.lastIndexOf("CustomerID>123456<")
> 0);
-    }
-    
-    private String source2String(Source source) throws Exception {
-        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);
-        return bos.toString();
-    }
-}
+/**
+ * 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 org.apache.cxf.systest.rest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+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;
+import javax.xml.ws.Dispatch;
+
+import javax.xml.ws.Service;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.cxf.systest.common.ClientServerSetupBase;
+import org.apache.cxf.systest.common.ClientServerTestBase;
+
+public class RestClientServerHttpBindingTest extends ClientServerTestBase {
+    private final QName serviceName = new QName("http://apache.org/hello_world_xml_http/wrapped",
+                                                "XMLService");
+
+    private final QName portName = new QName("http://apache.org/hello_world_xml_http/wrapped",
+                                             "RestProviderPort");
+
+    private final String endpointAddress =
+        "http://localhost:9024/XMLService/RestProviderPort/Customer"; 
+   
+    public static Test suite() throws Exception {
+        TestSuite suite = new TestSuite(RestClientServerHttpBindingTest.class);
+        return new ClientServerSetupBase(suite) {
+            public void startServers() throws Exception {
+                assertTrue("server did not launch correctly", launchServer(HttpBindingServer.class));
+            }
+        };
+    }    
+   
+    public void testHttpGET() throws Exception {
+        URL url = new URL(endpointAddress + "?name=john&address=20");
+        InputStream in = url.openStream();
+        assertNotNull(in);       
+    }
+
+    public void testHttpPOSTDispatchHTTPBinding() throws Exception {
+        Service service = Service.create(serviceName);
+        service.addPort(portName, HTTPBinding.HTTP_BINDING, endpointAddress);
+        Dispatch<Source> dispatcher = service.createDispatch(portName, Source.class,
Service.Mode.MESSAGE);
+        Map<String, Object> requestContext = dispatcher.getRequestContext();
+        requestContext.put(MessageContext.HTTP_REQUEST_METHOD, "POST");
+        InputStream is = getClass().getResourceAsStream("resources/CustomerJohnReq.xml");
+        Source result = dispatcher.invoke(new StreamSource(is));
+        String tempstring = source2String(result);
+        assertTrue("Result should start with Customer", tempstring.startsWith("<ns4:Customer"));
+        assertTrue("Result should have CustomerID", tempstring.lastIndexOf("CustomerID>123456<")
> 0);
+    }
+    
+    @SuppressWarnings("unchecked")
+    public void testHttpGETDispatchHTTPBinding() throws Exception { 
+        Service service = Service.create(serviceName); 
+        URI endpointURI = new URI(endpointAddress);
+        String path = null; 
+        if (endpointURI != null) { 
+            path = endpointURI.getPath(); 
+        } 
+        service.addPort(portName, HTTPBinding.HTTP_BINDING, endpointAddress);
+        Dispatch<Source> d = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
+        Map<String, Object> requestContext = d.getRequestContext();
+        Map<String, Object> responseContext = d.getResponseContext();
+        
+        requestContext.put(MessageContext.HTTP_REQUEST_METHOD, "GET");
+        requestContext.put(MessageContext.QUERY_STRING, "id=1"); 
+        //this is the original path part of uri 
+        requestContext.put(MessageContext.PATH_INFO, path);        
+        Source result = d.invoke(null);
+        
+        // varify the responseContext;
+        Map<String, List<String>> responseHeader =
+            (Map<String, List<String>>)responseContext.get(MessageContext.HTTP_RESPONSE_HEADERS);
+        assertNotNull("the response header should not be null", responseHeader);
+        
+        List<String> values = responseHeader.get("REST");
+        assertNotNull("the response rest header should not be null", values);
+        assertEquals("the list size wrong", 2, values.size());        
+        assertNotNull("result shoud not be null", result);        
+        String tempstring = source2String(result);
+        assertTrue("Result should start with Customer", tempstring.startsWith("<ns4:Customer"));
+        assertTrue("Result should have CustomerID", tempstring.lastIndexOf("CustomerID>123456<")
> 0);
+    }
+    
+    private String source2String(Source source) throws Exception {
+        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);
+        return bos.toString();
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerHttpBindingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerHttpBindingTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProviderHttpBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProviderHttpBinding.java?view=diff&rev=486085&r1=486084&r2=486085
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProviderHttpBinding.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProviderHttpBinding.java
Tue Dec 12 02:23:17 2006
@@ -1,111 +1,111 @@
-/**
- * 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 org.apache.cxf.systest.rest;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.ws.Provider;
-import javax.xml.ws.Service;
-import javax.xml.ws.ServiceMode;
-import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.WebServiceProvider;
-import javax.xml.ws.handler.MessageContext;
-
-import org.w3c.dom.Document;
-
-@WebServiceProvider()
-@ServiceMode(value = Service.Mode.PAYLOAD)
-public class RestSourcePayloadProviderHttpBinding implements Provider<DOMSource> {
-
-    @Resource
-    protected WebServiceContext wsContext;
-
-    public RestSourcePayloadProviderHttpBinding() {
-    }
-
-    @SuppressWarnings("unchecked")
-    public DOMSource invoke(DOMSource request) {
-        MessageContext mc = wsContext.getMessageContext();
-        String path = (String)mc.get(MessageContext.PATH_INFO);
-        String query = (String)mc.get(MessageContext.QUERY_STRING);
-        String httpMethod = (String)mc.get(MessageContext.HTTP_REQUEST_METHOD);
-        
-        Map<String, List<String>> responseHeader =
-            (Map<String, List<String>>)mc.get(MessageContext.HTTP_RESPONSE_HEADERS);
-        List<String> values = new ArrayList<String>();
-        values.add("hello1");
-        values.add("hello2");
-        responseHeader.put("REST", values);
-//        System.out.println("--path--- " + path);
-//        System.out.println("--query--- " + query);
-//        System.out.println("--httpMethod--- " + httpMethod);
-        
-        if (httpMethod.equalsIgnoreCase("POST")) {
-            // TBD: parse query info from DOMSource
-            // System.out.println("--POST: getAllCustomers--- ");
-            return getCustomer(null);
-        } else if (httpMethod.equalsIgnoreCase("GET")) {
-            if ("/XMLService/RestProviderPort/Customer".equals(path) && query ==
null) {
-                // System.out.println("--GET:getAllCustomers--- ");
-                return getAllCustomers();
-            } else if ("/XMLService/RestProviderPort/Customer".equals(path) && query
!= null) {
-                // System.out.println("--GET:getCustomer--- ");
-                return getCustomer(query);
-            }
-        }
-
-        return null;
-    }
-
-    private DOMSource getAllCustomers() {
-        return createDOMSource("resources/CustomerAllResp.xml");
-    }
-
-    private DOMSource getCustomer(String customerID) {
-        return createDOMSource("resources/CustomerJohnResp.xml");
-    }
-
-    private DOMSource createDOMSource(String fileName) {
-        DocumentBuilderFactory factory;
-        DocumentBuilder builder;
-        Document document = null;
-        DOMSource response = null;
-
-        try {
-            factory = DocumentBuilderFactory.newInstance();
-            factory.setValidating(true);
-            builder = factory.newDocumentBuilder();
-            InputStream greetMeResponse = getClass().getResourceAsStream(fileName);
-
-            document = builder.parse(greetMeResponse);
-            response = new DOMSource(document);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return response;
-    }       
-}
+/**
+ * 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 org.apache.cxf.systest.rest;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.handler.MessageContext;
+
+import org.w3c.dom.Document;
+
+@WebServiceProvider()
+@ServiceMode(value = Service.Mode.PAYLOAD)
+public class RestSourcePayloadProviderHttpBinding implements Provider<DOMSource> {
+
+    @Resource
+    protected WebServiceContext wsContext;
+
+    public RestSourcePayloadProviderHttpBinding() {
+    }
+
+    @SuppressWarnings("unchecked")
+    public DOMSource invoke(DOMSource request) {
+        MessageContext mc = wsContext.getMessageContext();
+        String path = (String)mc.get(MessageContext.PATH_INFO);
+        String query = (String)mc.get(MessageContext.QUERY_STRING);
+        String httpMethod = (String)mc.get(MessageContext.HTTP_REQUEST_METHOD);
+        
+        Map<String, List<String>> responseHeader =
+            (Map<String, List<String>>)mc.get(MessageContext.HTTP_RESPONSE_HEADERS);
+        List<String> values = new ArrayList<String>();
+        values.add("hello1");
+        values.add("hello2");
+        responseHeader.put("REST", values);
+//        System.out.println("--path--- " + path);
+//        System.out.println("--query--- " + query);
+//        System.out.println("--httpMethod--- " + httpMethod);
+        
+        if (httpMethod.equalsIgnoreCase("POST")) {
+            // TBD: parse query info from DOMSource
+            // System.out.println("--POST: getAllCustomers--- ");
+            return getCustomer(null);
+        } else if (httpMethod.equalsIgnoreCase("GET")) {
+            if ("/XMLService/RestProviderPort/Customer".equals(path) && query ==
null) {
+                // System.out.println("--GET:getAllCustomers--- ");
+                return getAllCustomers();
+            } else if ("/XMLService/RestProviderPort/Customer".equals(path) && query
!= null) {
+                // System.out.println("--GET:getCustomer--- ");
+                return getCustomer(query);
+            }
+        }
+
+        return null;
+    }
+
+    private DOMSource getAllCustomers() {
+        return createDOMSource("resources/CustomerAllResp.xml");
+    }
+
+    private DOMSource getCustomer(String customerID) {
+        return createDOMSource("resources/CustomerJohnResp.xml");
+    }
+
+    private DOMSource createDOMSource(String fileName) {
+        DocumentBuilderFactory factory;
+        DocumentBuilder builder;
+        Document document = null;
+        DOMSource response = null;
+
+        try {
+            factory = DocumentBuilderFactory.newInstance();
+            factory.setValidating(true);
+            builder = factory.newDocumentBuilder();
+            InputStream greetMeResponse = getClass().getResourceAsStream(fileName);
+
+            document = builder.parse(greetMeResponse);
+            response = new DOMSource(document);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return response;
+    }       
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProviderHttpBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProviderHttpBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message