You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by wo...@apache.org on 2009/03/25 23:06:42 UTC

svn commit: r758448 - in /webservices/axis2/trunk/java/modules: jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/ jaxws/src/org/apache/axis2/jaxws/client/dispatch/ jaxws/src/org/apache/axis2/jaxws/server/dispatcher/

Author: woodroy
Date: Wed Mar 25 22:06:35 2009
New Revision: 758448

URL: http://svn.apache.org/viewvc?rev=758448&view=rev
Log:
Cleanup for AXIS2-4100
Contributor: Roy Wood for Mike Rheinheimer

Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java?rev=758448&r1=758447&r2=758448&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java Wed Mar 25 22:06:35 2009
@@ -19,11 +19,8 @@
 
 package org.apache.axis2.jaxws.dispatch.server;
 
-import java.io.StringReader;
+import java.util.Iterator;
 
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 import javax.xml.ws.BindingType;
 import javax.xml.ws.Provider;
 import javax.xml.ws.Service;
@@ -36,12 +33,10 @@
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory;
-import org.apache.axis2.jaxws.ExceptionFactory;
 
 /**
  * A Provider<OMElement> implementation used to test sending and 
@@ -54,20 +49,23 @@
 @BindingType(SOAPBinding.SOAP12HTTP_BINDING)
 @ServiceMode(value=Service.Mode.MESSAGE)
 public class OMElementProvider implements Provider<OMElement> {
-    
-    private static final String sampleResponse = 
-        "<test:echoOMElement xmlns:test=\"http://org/apache/axis2/jaxws/test/OMELEMENT\">" +
-        "<test:input>SAMPLE RESPONSE MESSAGE</test:input>" +
-        "</test:echoOMElement>";
-    
-    private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
-    
+
     public OMElement invoke(OMElement obj) {
-        try {
-            System.out.println("MIKE: " + obj.toStringWithConsume());
-        } catch (XMLStreamException e) {
-            System.out.println("MIKE: PROBLEM");
+        // since this is test code, let's check the inbound obj:
+        SOAPEnvelope inboundEnv = (SOAPEnvelope)obj;
+        SOAPBody inboundBody = inboundEnv.getBody();
+        Iterator it = inboundBody.getChildren();
+        OMElement el3 = null;
+        for (;it.hasNext();) {
+            OMElement el2 = (OMElement)it.next();
+            Iterator it2 = el2.getChildElements();
+            for (;it2.hasNext();) {
+                el3 = (OMElement)it2.next();
+                assert(el3.getText().equals("SAMPLE REQUEST MESSAGE"));
+            }
         }
+        assert(el3 != null);
+
         OMElement payload = createPayload();
         
         SOAPFactory factory = new SOAP12Factory();

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java?rev=758448&r1=758447&r2=758448&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java Wed Mar 25 22:06:35 2009
@@ -182,9 +182,6 @@
                 block = message.getBodyBlock(null, factory);
                 if (block != null) {
                     value = block.getBusinessObject(true);
-                    if (value instanceof OMBlockFactoryImpl) {
-                        value = ((OMBlock)value).getOMElement();
-                    }
                 } else {
                     // REVIEW This seems like the correct behavior.  If the body is empty, return a null
                     // Any changes here should also be made to XMLDispatch.getValue
@@ -197,7 +194,18 @@
 
             } else if (mode.equals(Mode.MESSAGE)) {
                 BlockFactory factory = (BlockFactory)FactoryRegistry.getFactory(blockFactoryType);
-                if (factory instanceof OMBlockFactoryImpl) {
+
+                if (factory instanceof OMBlockFactory) {
+                    /*
+                     * see MessageImpl.getValue(Object, BlockFactory)
+                     * The getValue method is not performant; it uses an intermediate StringBlock.  To support OMElement in a
+                     * performant way, we simply retrieve the OMElement from the Message object, rather than unnecessarily
+                     * using the non-performant code in MessageImpl.getValue.
+                     * 
+                     * TODO:  when MessageImpl.getValue is fixed, this code can be removed, and the check for (value instanceof OMBlock)
+                     * placed below.  However, the solution here actually traverses less code, so perhaps it should remain as-is.
+                     */
+
                     value = (OMElement)message.getAsOMElement();
                 } else {
                     value = message.getValue(null, factory);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java?rev=758448&r1=758447&r2=758448&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java Wed Mar 25 22:06:35 2009
@@ -282,14 +282,21 @@
             Service.Mode providerServiceMode = endpointDesc.getServiceMode();
 
             if (providerServiceMode != null && providerServiceMode == Service.Mode.MESSAGE) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Provider type is " + providerType.getClass().getName());
+                }
                 if (providerType.equals(SOAPMessage.class)) {
                     // We can get the SOAPMessage directly from the message itself
                     if (log.isDebugEnabled()) {
-                        log.debug("Provider Type is SOAPMessage.");
                         log.debug("Number Message attachments=" + message.getAttachmentIDs().size());
                     }
                 }
                 if (providerType.equals(OMElement.class)) {
+                    // TODO avoid call to message.getValue due to
+                    // current unnecessary message transformation in
+                    // message.getValue.  Once message.getValue is fixed,
+                    // this code block is unnecessary, though no harm
+                    // will come if it remains.  rott
                     requestParamValue = message.getAsOMElement();
                 } else {
                     requestParamValue = message.getValue(null, factory);
@@ -307,6 +314,10 @@
                     try {
                         requestParamValue = block.getBusinessObject(true);
                         if (requestParamValue instanceof OMBlock) {
+                            // Provider<OMBlock> is not supported, so we need to get the OMElement out
+                            if (log.isDebugEnabled()) {
+                                log.debug("request parameter business object is OMBlock.  Now retrieving OMElement from OMBlock.");
+                            }
                             requestParamValue = ((OMBlock)requestParamValue).getOMElement();
                         }
                     } catch (WebServiceException e) {