You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2006/07/29 14:22:07 UTC

svn commit: r426787 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java test/org/apache/axis2/jaxws/message/MessageTests.java

Author: scheu
Date: Sat Jul 29 05:22:07 2006
New Revision: 426787

URL: http://svn.apache.org/viewvc?rev=426787&view=rev
Log:
AXIS2-930
NPE Fix
Contributor: Nick Gallardo

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java?rev=426787&r1=426786&r2=426787&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java Sat Jul 29 05:22:07 2006
@@ -106,11 +106,14 @@
 		bodyIterator = null;
 		
 		
-		// Create an OMBlock for each header element
+		// If a header block exists, create an OMBlock for each element
 		// This advances the StAX parser past the header end tag
 		SOAPHeader header = root.getHeader();
-		Iterator it = header.getChildren();
-		advanceIterator(it, headerBlocks, true);
+		if (header != null) {
+            Iterator it = header.getChildren();
+            advanceIterator(it, headerBlocks, true);            
+        }
+
 		
 		SOAPBody body = root.getBody();
 		if (!body.hasFault()) {

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java?rev=426787&r1=426786&r2=426787&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java Sat Jul 29 05:22:07 2006
@@ -48,11 +48,11 @@
 public class MessageTests extends TestCase {
 
 	// String test variables
-    private static final String sampleEnvelopeHeader =
+    private static final String sampleEnvelopeHead =
         "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
         "<soapenv:Header /><soapenv:Body>";
     
-    private static final String sampleEnvelopeFooter = 
+    private static final String sampleEnvelopeTail = 
         "</soapenv:Body></soapenv:Envelope>";
     
     private static final String sampleText =
@@ -62,9 +62,9 @@
 		"</pre:a>";
 	
     private static final String sampleEnvelope = 
-        sampleEnvelopeHeader +
+        sampleEnvelopeHead +
         sampleText +
-        sampleEnvelopeFooter;
+        sampleEnvelopeTail;
         
     private static final String sampleJAXBText = 
         "<echoStringResponse xmlns=\"http://test\">" +
@@ -72,10 +72,16 @@
         "</echoStringResponse>";
     
     private static final String sampleJAXBEnvelope = 
-        sampleEnvelopeHeader + 
+        sampleEnvelopeHead + 
         sampleJAXBText + 
-        sampleEnvelopeFooter;
+        sampleEnvelopeTail;
 
+    private static final String sampleEnvelopeNoHeader =
+        "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+        "<soapenv:Body>" + 
+        sampleText + 
+        "</soapenv:Body></soapenv:Envelope>";
+    
 	private static final QName sampleQName = new QName("urn://sample", "a");
 	
 	private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
@@ -262,6 +268,42 @@
 		assertTrue(sampleText.equals(bo.toString()));
 		
 	}
+    
+    /**
+     * Create a Block representing an XMLString, but this time use one that
+     * doesn't have a &lt;soap:Header&gt; element in it.
+     * @throws Exception
+     */
+    public void testStringInflow3() throws Exception {
+        
+        // On inbound, there will already be an OM
+        // which represents the message.  The following code simulates the input
+        // OM
+        StringReader sr = new StringReader(sampleEnvelopeNoHeader);
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+        OMElement omElement = builder.getSOAPEnvelope();
+        
+        // The JAX-WS layer creates a Message from the OM
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.createFrom(omElement);
+        
+        // The next thing that will happen
+        // is the proxy code will ask for the business object (String).
+        XMLStringBlockFactory blockFactory = 
+            (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = m.getBodyBlock(0, null, blockFactory);
+        Object bo = block.getBusinessObject(true);
+        assertTrue(bo instanceof String);
+        
+        // The block should be consumed
+        assertTrue(block.isConsumed());
+        
+        // Check the String for accuracy
+        assertTrue(sampleText.equals(bo.toString()));
+        
+    }
     
     /**
      * Create a JAXBBlock containing a JAX-B business object 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org