cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r446570 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/bus/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/ rt/frontend/jaxws/src/test/java/org/apache/cxf/...
Date Fri, 15 Sep 2006 11:00:49 GMT
Author: jliu
Date: Fri Sep 15 04:00:48 2006
New Revision: 446570

URL: http://svn.apache.org/viewvc?view=rev&rev=446570
Log:
[JIRA CXF-42] [JIRA CXF-83] 
* Support the injection of WebServiceContext.
* Using JAX-WS provider on the server side to process a restful xml message.
* Added system test for a restful JAX-WS provider.

Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebContextResourceResolver.java
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProvider.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnReq.xml
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnResp.xml
  (with props)
Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBus.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderInvoker.java
    incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBus.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBus.java?view=diff&rev=446570&r1=446569&r2=446570
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBus.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBus.java Fri Sep 15 04:00:48
2006
@@ -87,7 +87,9 @@
         
         ResourceResolver busResolver = new SinglePropertyResolver(BUS_PROPERTY_NAME, this);
         resourceManager.addResourceResolver(busResolver);
-   
+        
+        extensions.put(ResourceManager.class, resourceManager);
+
         new ExtensionManagerImpl(BUS_EXTENSION_RESOURCE, 
                                                     Thread.currentThread().getContextClassLoader(),
                                                     extensions,

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view=diff&rev=446570&r1=446569&r2=446570
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Fri Sep 15 04:00:48 2006
@@ -34,22 +34,27 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
+import org.apache.cxf.common.injection.ResourceInjector;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.EndpointException;
 import org.apache.cxf.endpoint.ServerImpl;
+import org.apache.cxf.jaxws.context.WebContextResourceResolver;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.jaxws.support.JaxwsEndpointImpl;
 import org.apache.cxf.jaxws.support.JaxwsImplementorInfo;
+import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.ChainInitiationObserver;
 import org.apache.cxf.transport.MessageObserver;
 
 public class EndpointImpl extends javax.xml.ws.Endpoint {
-
+ 
     private static final Logger LOG = LogUtils.getL7dLogger(JaxWsServiceFactoryBean.class);
     private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
 
+    protected boolean doInit;
+
     private Bus bus;
     // private String bindingURI;
     private Object implementor;
@@ -58,7 +63,7 @@
     private JaxwsEndpointImpl endpoint;
     
     private JaxwsImplementorInfo implInfo;
-
+    
     @SuppressWarnings("unchecked")
     public EndpointImpl(Bus b, Object i, String uri) {
         bus = b;
@@ -88,6 +93,41 @@
         } catch (EndpointException e) {
             throw new WebServiceException(e);
         }
+        
+        doInit = true;
+    }
+
+    private synchronized void init() {
+        if (doInit) {
+            try {
+                injectResources(implementor);
+    
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                if (ex instanceof WebServiceException) { 
+                    throw (WebServiceException)ex; 
+                }
+                throw new WebServiceException("Creation of Endpoint failed", ex);
+            }
+        }
+        doInit = false;
+    }
+
+    /**
+     * inject resources into servant.  The resources are injected
+     * according to @Resource annotations.  See JSR 250 for more
+     * information.
+     */
+    /**
+     * @param instance
+     */
+    protected void injectResources(Object instance) {
+        if (instance != null) {
+            ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
+            resourceManager.addResourceResolver(new WebContextResourceResolver());
+            ResourceInjector injector = new ResourceInjector(resourceManager);
+            injector.inject(instance);
+        }
     }
 
     public Binding getBinding() {
@@ -158,10 +198,12 @@
     }
 
     protected void doPublish(String address) {
+        init();
+        
         if (null != address) {
             endpoint.getEndpointInfo().setAddress(address);
         }
-
+        
         try {
             MessageObserver observer = null;
             if (implInfo.isWebServiceProvider()) {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderInvoker.java?view=diff&rev=446570&r1=446569&r2=446570
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderInvoker.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderInvoker.java
Fri Sep 15 04:00:48 2006
@@ -20,7 +20,10 @@
 package org.apache.cxf.jaxws;
 
 import javax.xml.ws.Provider;
+import javax.xml.ws.handler.MessageContext;
 
+import org.apache.cxf.jaxws.context.WebServiceContextImpl;
+import org.apache.cxf.jaxws.context.WrappedMessageContext;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.service.invoker.Invoker;
 
@@ -35,7 +38,9 @@
 
     @SuppressWarnings("unchecked")
     public Object invoke(Exchange exchange, Object o) {
-
+        MessageContext ctx = new WrappedMessageContext(exchange.getInMessage());
+        WebServiceContextImpl.setMessageContext(ctx);
+ 
         if (provider != null) {
             return (T)provider.invoke((T)o);
         } else {

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebContextResourceResolver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebContextResourceResolver.java?view=auto&rev=446570
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebContextResourceResolver.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebContextResourceResolver.java
Fri Sep 15 04:00:48 2006
@@ -0,0 +1,41 @@
+/**
+ * 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.jaxws.context;
+
+import java.io.InputStream;
+import javax.xml.ws.WebServiceContext;
+import org.apache.cxf.resource.ResourceResolver;
+
+
+public class WebContextResourceResolver implements ResourceResolver {
+
+    // Implementation of org.objectweb.celtix.resource.ResourceResolver
+
+    public final InputStream getAsStream(final String string) {
+        return null;
+    }
+
+    public final <T> T resolve(final String string, final Class<T> clz) {
+        if (WebServiceContext.class.isAssignableFrom(clz)) {
+            return clz.cast(new WebServiceContextImpl());
+        }
+        return null;
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebContextResourceResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebContextResourceResolver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java?view=auto&rev=446570
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
Fri Sep 15 04:00:48 2006
@@ -0,0 +1,137 @@
+/**
+ * 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.jaxws;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.soap.SoapBindingFactory;
+import org.apache.cxf.binding.soap.SoapDestinationFactory;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.test.AbstractCXFTest;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.ConduitInitiatorManager;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.hello_world_soap_http.GreeterImpl;
+import org.xmlsoap.schemas.wsdl.http.AddressType;
+
+public class EndpointImplTest extends AbstractCXFTest {
+
+    private Bus bus;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        
+        bus = getBus();
+        
+        SoapBindingFactory bindingFactory = new SoapBindingFactory();
+
+        bus.getExtension(BindingFactoryManager.class)
+            .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
+
+        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+        SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
+
+        LocalTransportFactory localTransport = new LocalTransportFactory();
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
+
+        ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
+        extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
+        extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
+        extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
+        
+        EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
+        AddressType a = new AddressType();
+        a.setLocation("http://localhost:9000/SoapContext/SoapPort");
+        ei.addExtensor(a);
+
+        Destination d = localTransport.getDestination(ei);
+        d.setMessageObserver(new EchoObserver());
+    }
+
+    public void testEndpoint() throws Exception {   
+        GreeterImpl greeter = new GreeterImpl();
+        EndpointImpl endpoint = new EndpointImpl(bus, greeter, "anyuri");
+ 
+        WebServiceContext ctx = greeter.getContext();
+        assertNull(ctx);
+        try {
+            String address = "http://localhost:8080/test";
+            endpoint.publish(address);
+        } catch (IllegalArgumentException ex) {
+            //assertTrue(ex.getCause() instanceof BusException);
+            //assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+        }
+        ctx = greeter.getContext();
+        
+        assertNotNull(ctx);
+        
+    }
+
+    static class EchoObserver implements MessageObserver {
+
+        public void onMessage(Message message) {
+            try {
+                Conduit backChannel = message.getDestination().getBackChannel(message, null,
null);
+
+                backChannel.send(message);
+
+                OutputStream out = message.getContent(OutputStream.class);
+                assertNotNull(out);
+                InputStream in = message.getContent(InputStream.class);
+                assertNotNull(in);
+                
+                copy(in, out, 2045);
+
+                out.close();
+                in.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    private static void copy(final InputStream input, final OutputStream output, final int
bufferSize)
+        throws IOException {
+        try {
+            final byte[] buffer = new byte[bufferSize];
+
+            int n = input.read(buffer);
+            while (-1 != n) {
+                output.write(buffer, 0, n);
+                n = input.read(buffer);
+            }
+        } finally {
+            input.close();
+            output.close();
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java?view=auto&rev=446570
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
Fri Sep 15 04:00:48 2006
@@ -0,0 +1,79 @@
+/**
+ * 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.jaxws.context;
+
+
+
+import javax.xml.ws.handler.MessageContext;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.message.MessageImpl;
+
+
+public class WebServiceContextImplTest extends TestCase {
+
+    public void tearDown() { 
+        WebServiceContextImpl.clear();
+    } 
+
+    public void testConstructor() { 
+        MessageImpl msg = new MessageImpl();
+        WrappedMessageContext msgCtx = new WrappedMessageContext(msg); 
+        WebServiceContextImpl ctx = new WebServiceContextImpl(msgCtx);
+        assertSame(msgCtx, ctx.getMessageContext());
+    }     
+
+    public void testGetSetMessageContext() { 
+        WebServiceContextImpl wsci = new WebServiceContextImpl(); 
+        assertNull(wsci.getMessageContext());
+        
+        MessageImpl msg = new MessageImpl();
+        final MessageContext ctx = new WrappedMessageContext(msg);
+        WebServiceContextImpl.setMessageContext(ctx);
+
+        assertSame(ctx, wsci.getMessageContext());
+
+        Thread t = new Thread() { 
+                public void run() {
+                    WebServiceContextImpl threadLocalWSCI = new WebServiceContextImpl();

+
+                    assertNull(threadLocalWSCI.getMessageContext());
+
+                    MessageImpl msg1 = new MessageImpl();
+                    MessageContext threadLocalCtx = new WrappedMessageContext(msg1); 
+                    WebServiceContextImpl.setMessageContext(threadLocalCtx);
+
+
+                    assertSame(threadLocalCtx, threadLocalWSCI.getMessageContext());
+                    assertTrue(ctx !=  threadLocalWSCI.getMessageContext());
+                    
+                }
+            };
+
+        t.start(); 
+        
+        try {
+            t.join();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    } 
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java?view=auto&rev=446570
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerTest.java
Fri Sep 15 04:00:48 2006
@@ -0,0 +1,107 @@
+/**
+ * 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.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.systest.common.ClientServerSetupBase;
+import org.apache.cxf.systest.common.ClientServerTestBase;
+import org.apache.cxf.systest.common.TestServerBase;
+import org.apache.hello_world_xml_http.wrapped.XMLService;
+
+public class RestClientServerTest 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");
+
+    public static class Server extends TestServerBase {
+
+        protected void run() {
+            Object implementor = new RestSourcePayloadProvider();
+            String address = "http://localhost:9023/XMLService/RestProviderPort";
+            Endpoint.publish(address, implementor);
+        }
+
+        public static void main(String[] args) {
+            try {
+                Server s = new Server();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                System.out.println("done!");
+            }
+        }
+    }
+
+    public static Test suite() throws Exception {
+        TestSuite suite = new TestSuite(RestClientServerTest.class);
+        return new ClientServerSetupBase(suite) {
+            public void startServers() throws Exception {
+                assertTrue("server did not launch correctly",
+                        launchServer(Server.class));
+            }
+        };
+    }
+
+    public void testDOMSourcePAYLOAD() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl");
+        assertNotNull(wsdl);
+
+        XMLService service = new XMLService(wsdl, serviceName);
+        assertNotNull(service);
+
+        InputStream is = getClass().getResourceAsStream(
+                "resources/CustomerJohnReq.xml");
+        Document doc = XMLUtils.parse(is);
+        DOMSource reqMsg = new DOMSource(doc);
+        assertNotNull(reqMsg);
+
+        Dispatch<DOMSource> disp = service.createDispatch(portName,
+                DOMSource.class, Service.Mode.PAYLOAD);
+        DOMSource result = disp.invoke(reqMsg);
+        assertNotNull(result);
+
+        Node respDoc = result.getNode();
+        assertEquals("Customer", respDoc.getFirstChild().getLocalName());
+        /*
+         * assertEquals("TestXMLBindingProviderMessage", respDoc.getFirstChild()
+         * .getTextContent());
+         */
+    }
+
+}

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

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProvider.java?view=auto&rev=446570
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProvider.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestSourcePayloadProvider.java
Fri Sep 15 04:00:48 2006
@@ -0,0 +1,89 @@
+/**
+ * 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 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;
+
+import org.apache.cxf.message.Message;
+
+
+//The following wsdl file is used.
+//wsdlLocation = "/trunk/testutils/src/main/resources/wsdl/hello_world_rpc_lit.wsdl"
+@WebServiceProvider(portName = "XMLProviderPort",
+        serviceName = "SOAPServiceRPCLit2",
+        targetNamespace = "http://apache.org/hello_world_rpclit",
+        wsdlLocation = "/wsdl/hello_world_rpc_lit.wsdl")
+@ServiceMode(value = Service.Mode.PAYLOAD)
+@javax.xml.ws.BindingType(value = "http://cxf.apache.org/bindings/xformat")
+public class RestSourcePayloadProvider implements
+        Provider<DOMSource> {
+
+    @Resource
+    protected WebServiceContext wsContext;
+
+    public RestSourcePayloadProvider() {
+    }
+
+    public DOMSource invoke(DOMSource request) {
+        MessageContext mc = wsContext.getMessageContext();
+        //String path1 = (String) mc.get(MessageContext.PATH_INFO);
+        String path = (String) mc.get(Message.PATH_INFO);
+
+        if (path.equals("/XMLService/RestProviderPort")) {
+            return getCustomer(null);
+        }
+
+        return null;
+    }
+    
+    private DOMSource getCustomer(String customerID) {
+        DocumentBuilderFactory factory;
+        DocumentBuilder builder;
+        Document document = null;
+        DOMSource response = null;
+
+        try {
+            factory = DocumentBuilderFactory.newInstance();
+            factory.setValidating(true);
+            builder = factory.newDocumentBuilder();
+            InputStream greetMeResponse = getClass().getResourceAsStream(
+                    "resources/CustomerJohnResp.xml");
+
+            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/RestSourcePayloadProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnReq.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnReq.xml?view=auto&rev=446570
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnReq.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnReq.xml
Fri Sep 15 04:00:48 2006
@@ -0,0 +1,3 @@
+<tns:Customer xmlns:tns="http://apache.org/hello_world_soap_http/types">
+  <tns:CustomerID>123456</tns:CustomerID>
+</tns:Customer>
\ No newline at end of file

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

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

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnReq.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnResp.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnResp.xml?view=auto&rev=446570
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnResp.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnResp.xml
Fri Sep 15 04:00:48 2006
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ns4:Customer xmlns:ns4="http://apache.org/hello_world_soap_http/types">
+  <ns4:CustomerName>John</ns4:CustomerName>
+  <ns4:CustomerID>123456</ns4:CustomerID>
+</ns4:Customer> 

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

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

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/CustomerJohnResp.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java?view=diff&rev=446570&r1=446569&r2=446570
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
(original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
Fri Sep 15 04:00:48 2006
@@ -23,9 +23,12 @@
 import java.util.concurrent.Future;
 import java.util.logging.Logger;
 
+import javax.annotation.Resource;
+
 import javax.jws.WebService;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceContext;
 
 import org.apache.hello_world_soap_http.types.BareDocumentResponse;
 import org.apache.hello_world_soap_http.types.ErrorCode;
@@ -35,25 +38,32 @@
 import org.apache.hello_world_soap_http.types.SayHiResponse;
 import org.apache.hello_world_soap_http.types.TestDocLitFaultResponse;
 
-@WebService(serviceName = "SOAPService", 
-            portName = "SoapPort", 
+@WebService(serviceName = "SOAPService",
+            portName = "SoapPort",
             endpointInterface = "org.apache.hello_world_soap_http.Greeter",
             targetNamespace = "http://apache.org/hello_world_soap_http")
 public class GreeterImpl implements Greeter {
-    
+
     private static final Logger LOG = Logger.getLogger(GreeterImpl.class.getName());
 
+    @Resource
+    private WebServiceContext context;
+
     private int invocationCount;
-    
+
+    public WebServiceContext getContext() {
+        return context;
+    }
+
     public String greetMe(String me) {
-        LOG.info("Invoking greetMe");        
+        LOG.info("Invoking greetMe");
         invocationCount++;
         return "Hello " + me;
     }
 
     public String sayHi() {
         LOG.info("Invoking sayHi");
-        invocationCount++;        
+        invocationCount++;
         return "Bonjour";
     }
 
@@ -77,13 +87,13 @@
         invocationCount++;
         System.out.println("*********  greetMeOneWay: " + requestType);
     }
-    
+
     public String greetMeSometime(String me) {
         invocationCount++;
         //System.err.println("In greetMeSometime: " + me);
         return "How are you " + me;
     }
-    
+
     public BareDocumentResponse testDocLitBare(String in) {
         invocationCount++;
         BareDocumentResponse res = new BareDocumentResponse();
@@ -91,74 +101,74 @@
         res.setId(1);
         return res;
     }
-    
-    public Future<?>  greetMeSometimeAsync(String requestType, 
+
+    public Future<?>  greetMeSometimeAsync(String requestType,
                                            AsyncHandler<GreetMeSometimeResponse> asyncHandler)
{
         invocationCount++;
         System.err.println("In greetMeSometimeAsync 1");
-        return null; 
+        return null;
         /*not called */
     }
-    
-    public Response<GreetMeSometimeResponse> greetMeSometimeAsync(String requestType)
{ 
+
+    public Response<GreetMeSometimeResponse> greetMeSometimeAsync(String requestType)
{
         invocationCount++;
         System.err.println("In greetMeSometimeAsync 2");
-        return null; 
+        return null;
         /*not called */
     }
-    
-    public Response<TestDocLitFaultResponse> testDocLitFaultAsync(String faultType)
{  
+
+    public Response<TestDocLitFaultResponse> testDocLitFaultAsync(String faultType)
{
         invocationCount++;
         System.err.println("In testDocLitFaultAsync 1");
-        return null; 
+        return null;
         /*not called */
     }
-    
-    public Future<?> testDocLitFaultAsync(String faultType, AsyncHandler ah) {  
+
+    public Future<?> testDocLitFaultAsync(String faultType, AsyncHandler ah) {
         invocationCount++;
         System.err.println("In testDocLitFaultAsync 2");
-        return null; 
+        return null;
         /*not called */
     }
-    
+
     public Future<?> testDocLitBareAsync(String bare, AsyncHandler ah) {
         invocationCount++;
         return null;
         /* not called */
     }
-    
+
     public Response<BareDocumentResponse> testDocLitBareAsync(String bare) {
         invocationCount++;
         return null;
         /* not called */
     }
-    
-    public Future<?> greetMeAsync(String requestType, AsyncHandler<GreetMeResponse>
asyncHandler) { 
+
+    public Future<?> greetMeAsync(String requestType, AsyncHandler<GreetMeResponse>
asyncHandler) {
         invocationCount++;
-        return null; 
+        return null;
         /*not called */
     }
-    
-    public Response<GreetMeResponse> greetMeAsync(String requestType) { 
+
+    public Response<GreetMeResponse> greetMeAsync(String requestType) {
         invocationCount++;
-        return null; 
+        return null;
         /*not called */
     }
-    
-    public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) { 
+
+    public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) {
         invocationCount++;
-        return null; 
+        return null;
         /*not called */
     }
-    
-    public Response<SayHiResponse> sayHiAsync() { 
+
+    public Response<SayHiResponse> sayHiAsync() {
         invocationCount++;
-        return null; 
+        return null;
         /*not called */
     }
 
     public int getInvocationCount() {
         return invocationCount;
     }
-    
+
 }

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl?view=diff&rev=446570&r1=446569&r2=446570
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_xml_wrapped.wsdl Fri
Sep 15 04:00:48 2006
@@ -172,6 +172,11 @@
 		<wsdl:port binding="tns:Greeter_XMLBinding" name="XMLProviderPort">
 			<http:address
 				location="http://localhost:9022/XMLService/XMLProviderPort" />
+		</wsdl:port>
+		
+		<wsdl:port binding="tns:Greeter_XMLBinding" name="RestProviderPort">
+			<http:address
+				location="http://localhost:9023/XMLService/RestProviderPort" />
 		</wsdl:port>		
 	</wsdl:service>
 </wsdl:definitions>



Mime
View raw message