axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntha...@apache.org
Subject svn commit: r767971 - in /webservices/axis2/trunk/java/modules: jaxws-integration/ jaxws-integration/test/org/apache/axis2/jaxws/dispatch/ jaxws-integration/test/org/apache/axis2/jaxws/provider/ jaxws-integration/test/org/apache/axis2/jaxws/provider/om...
Date Thu, 23 Apr 2009 16:45:26 GMT
Author: nthaker
Date: Thu Apr 23 16:45:26 2009
New Revision: 767971

URL: http://svn.apache.org/viewvc?rev=767971&view=rev
Log:
AXIS2-4323
Performance improvement for JAX-WS Provider<OM>

Added:
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/OMProviderTests.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/om/
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/om/OMProvider.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageFactoryImpl.java

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml?rev=767971&r1=767970&r2=767971&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml Thu Apr 23 16:45:26 2009
@@ -1283,7 +1283,15 @@
 									basedir="${pom.basedir}/target/test-classes/servicejars/HandlerHeaderService"
 								/>
 								<delete dir="target/test-classes/servicejars/HandlerHeaderService"/>
-								
+                                <copy toDir="target/test-classes/servicejars/OMProviderService/">
+									<fileset dir="target/test-classes">
+									   <include name="org/apache/axis2/jaxws/provider/om/**"/>
+									</fileset>
+								</copy>
+								<zip destfile="target/test-classes/servicejars/OMProviderService.jar"
+						             basedir="${pom.basedir}/target/test-classes/servicejars/OMProviderService"
+						        />
+						        <delete dir="target/test-classes/servicejars/OMProviderService"/>   
  
                                 <copy toDir="target/test-classes/">
                                     <fileset dir="test-resources/">
                                         <include name="**/*.properties"/>
@@ -1400,6 +1408,7 @@
                         <include>**/SOAPBindingProviderTests.java</include>
                         <include>**/SoapMessageProviderTests.java</include>
                         <include>**/StringProviderTests.java</include>
+                        <include>**/OMProviderTests.java</include>
                         
                     </includes>
                     <systemProperties>

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java?rev=767971&r1=767970&r2=767971&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java
Thu Apr 23 16:45:26 2009
@@ -41,6 +41,8 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.apache.axis2.jaxws.framework.AbstractTestCase;
 
 /**
@@ -274,10 +276,11 @@
         // we're in PAYLOAD mode, we don't have to worry about the envelope.
         StringReader sr = new StringReader(sampleEnvelope);
         XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
-        StAXOMBuilder builder = new StAXOMBuilder(inputReader);  
-        OMElement om = builder.getDocumentElement();
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
+        SOAPEnvelope soap12Envelope = (SOAPEnvelope) builder.getDocumentElement();
         
-        OMElement response = dispatch.invoke(om);
+        
+        OMElement response = dispatch.invoke(soap12Envelope);
         
         // Check to make sure the contents of the message are correct
         //String responseText = baos.toString();
@@ -296,8 +299,8 @@
         
         StringReader sr2 = new StringReader(sampleEnvelope);
         inputReader = inputFactory.createXMLStreamReader(sr2);
-        builder = new StAXOMBuilder(inputReader);  
-        om = builder.getDocumentElement();
+        builder = new StAXSOAPModelBuilder(inputReader, null);  
+        SOAPEnvelope om = (SOAPEnvelope)builder.getDocumentElement();
         response = dispatch.invoke(om);
         
         // Check to make sure the contents of the message are correct

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/OMProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/OMProviderTests.java?rev=767971&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/OMProviderTests.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/OMProviderTests.java
Thu Apr 23 16:45:26 2009
@@ -0,0 +1,81 @@
+package org.apache.axis2.jaxws.provider;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.soap.SOAPBinding;
+
+import java.io.StringReader;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class OMProviderTests extends ProviderTestCase {
+
+    String endpointUrl = "http://localhost:6060/axis2/services/OMProviderService.OMProviderPort";
+    private QName serviceName = new QName("http://ws.apache.org/axis2", "OMProviderService");
+    
+        private static final String SOAP11_NS_URI = "http://schemas.xmlsoap.org/soap/envelope/";
+
+        /**
+         * SOAP 1.1 header
+         */
+        private static final String SOAP11_ENVELOPE_HEAD = "<?xml version='1.0' encoding='utf-8'?>"
+                        + "<soapenv:Envelope xmlns:soapenv=\""
+                        + SOAP11_NS_URI
+                        + "\">"
+                        + "<soapenv:Header />" + "<soapenv:Body>";
+
+        /**
+         * SOAP 1.1 footer
+         */
+        private static final String SOAP11_ENVELOPE_TAIL = "</soapenv:Body>"
+                        + "</soapenv:Envelope>";
+
+
+        private static String request = "<invokeOp>Hello Provider OM</invokeOp>";
+        private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        
+   public static Test suite() {
+      return getTestSetup(new TestSuite(OMProviderTests.class));
+   }
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+    
+    /**
+     * Test sending a SOAP 1.2 request in MESSAGE mode
+     */
+    public void testOMElementDispatchMessageMode() throws Exception {
+        // Create the JAX-WS client needed to send the request
+        Service service = Service.create(serviceName);
+        service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
+        Dispatch<OMElement> dispatch = service.createDispatch(
+                portName, OMElement.class, Mode.MESSAGE);
+        
+        // Create the OMElement object with the payload contents.  Since
+        // we're in PAYLOAD mode, we don't have to worry about the envelope.
+        StringReader sr = new StringReader(SOAP11_ENVELOPE_HEAD+request+SOAP11_ENVELOPE_TAIL);
+        XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
+        SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();
+
+        
+        OMElement response = dispatch.invoke(om);
+        
+        
+        String responseText = response.toStringWithConsume();
+        assertTrue(responseText.contains("soap"));
+        assertTrue(responseText.contains("Body"));
+        assertTrue(responseText.contains("Envelope"));
+        assertTrue(responseText.contains("Hello Dispatch OM"));
+        
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/om/OMProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/om/OMProvider.java?rev=767971&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/om/OMProvider.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/om/OMProvider.java
Thu Apr 23 16:45:26 2009
@@ -0,0 +1,82 @@
+/*
+ * 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.axis2.jaxws.provider.om;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceProvider;
+
+import java.io.StringReader;
+
+@WebServiceProvider(serviceName="OMProviderService")
+@ServiceMode(value=Service.Mode.MESSAGE)
+public class OMProvider implements Provider<OMElement> {
+    private static final String SOAP11_NS_URI = "http://schemas.xmlsoap.org/soap/envelope/";
+
+    /**
+     * SOAP 1.1 header
+     */
+    private static final String SOAP11_ENVELOPE_HEAD = "<?xml version='1.0' encoding='utf-8'?>"
+                    + "<soapenv:Envelope xmlns:soapenv=\""
+                    + SOAP11_NS_URI
+                    + "\">"
+                    + "<soapenv:Header />" + "<soapenv:Body>";
+
+    /**
+     * SOAP 1.1 footer
+     */
+    private static final String SOAP11_ENVELOPE_TAIL = "</soapenv:Body>"
+                    + "</soapenv:Envelope>";
+
+
+    private static String response = "<invokeOp>Hello Dispatch OM</invokeOp>";
+    private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+    public OMElement invoke(OMElement om) {
+        try{
+            StringReader sr = null;
+           if(om!=null){
+             String requestText = om.toStringWithConsume();
+             if((requestText.contains("Hello Provider OM"))){
+                 sr = new StringReader(SOAP11_ENVELOPE_HEAD+response+SOAP11_ENVELOPE_TAIL);
+             }
+             if((!requestText.contains("Hello Provider OM"))){
+                 sr = new StringReader(SOAP11_ENVELOPE_HEAD+"ack:received OM"+SOAP11_ENVELOPE_TAIL);
+             }
+           }else{
+               sr = new StringReader(SOAP11_ENVELOPE_HEAD+"null request"+SOAP11_ENVELOPE_TAIL);
+           }
+            XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
+            StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
+            SOAPEnvelope responseOM = (SOAPEnvelope) builder.getDocumentElement();
+
+            return responseOM;
+        }catch(Exception e){
+            throw new WebServiceException(e);
+        }
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageFactoryImpl.java?rev=767971&r1=767970&r2=767971&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageFactoryImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageFactoryImpl.java
Thu Apr 23 16:45:26 2009
@@ -32,6 +32,7 @@
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.databinding.OMBlock;
 import org.apache.axis2.jaxws.message.databinding.SOAPEnvelopeBlock;
 import org.apache.axis2.jaxws.message.databinding.DataSourceBlock;
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
@@ -137,6 +138,9 @@
             return new MessageImpl((SOAPEnvelope)block.getBusinessObject(true), protocol);
         } else if (block instanceof DataSourceBlock) {
             return createFrom(block.getOMElement(), protocol);
+        } else if (block instanceof OMBlock){
+           	OMBlock omblock = (OMBlock)block;
+        	return new MessageImpl((OMElement)omblock.getBusinessObject(true), protocol);
         }
         return createFrom(block.getXMLStreamReader(true), protocol);
     }



Mime
View raw message