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 "Matti Aarnio (JIRA)" <ax...@ws.apache.org> on 2013/04/18 00:33:16 UTC

[jira] [Comment Edited] (AXIS-2633) The Axis DOM implementation is improperly stripping whitespace from the beginning and end of Text nodes

    [ https://issues.apache.org/jira/browse/AXIS-2633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13634532#comment-13634532 ] 

Matti Aarnio edited comment on AXIS-2633 at 4/17/13 10:31 PM:
--------------------------------------------------------------

I did experiment a bit by dropping the stripping at SoapHandler.addTextNode(), and then feeding pretty-printed SOAP requests to modified Axis 1.4.
Both SOAPHeader.java  and  SOAPBody.java  did not expect to see Text elements, and needed to be fixed to ignore those.
.. but only if the said nodes are fully ignorable (contain only SP/CR/LF/TAB.)

So this approach replaces BIG trouble with e.g. XMLDSig data with smaller trouble at SOAPHeader and SOAPBody classes.

The SOAPBody should really be able to handle a Text element, but even simply ignoring them when collecting top-level elements under the SOAPBody, and using HighFidelity record will preserve the XMLDSig.  (We route SOAP requests and responses over multiple nodes, and must preserve XML digital signatures.)
                
      was (Author: oh2mqk):
    I did experiment a bit by dropping the stripping at SOapHandler.addTextNode(), and then feeding pretty-printed SOAP requests to modified Axis 1.4.
Both SOAPHeader.java  and  SOAPBody.java  did not expect to see Text elements, and needed to be fixed to ignore those.
.. but only if the said nodes are fully ignorable (contain only SP/CR/LF/TAB.)

So this approach replaces BIG trouble with e.g. XMLDSig data with smaller trouble at SOAPHeader and SOAPBody classes.

The SOAPBody should really be able to handle a Text element, but even simply ignoring them when collecting top-level elements under the SOAPBody, and using HighFidelity record will preserve the XMLDSig.  (We route SOAP requests and responses over multiple nodes, and must preserve XML digital signatures.)
                  
> The Axis DOM implementation is improperly stripping whitespace from the beginning and end of Text nodes
> -------------------------------------------------------------------------------------------------------
>
>                 Key: AXIS-2633
>                 URL: https://issues.apache.org/jira/browse/AXIS-2633
>             Project: Axis
>          Issue Type: Bug
>          Components: Serialization/Deserialization
>    Affects Versions: 1.2, 1.2.1, 1.3, 1.4
>         Environment: Windows XP, Sun JDK 1.4
>            Reporter: Michael Theroux
>
> Axis's DOM implementation is improperly stripping whitespace from the beginning and end of text nodes of SOAP envelopes.  The following code snippet tries to concisely show the issue:
> import java.util.Iterator;
> import org.apache.axis.SimpleChain;
> import org.apache.axis.client.Call;
> import org.apache.axis.client.Service;
> import org.apache.axis.handlers.LogHandler;
> import org.apache.axis.message.RPCParam;
> import org.w3c.dom.Node;
> import org.w3c.dom.NodeList;
> import javax.xml.namespace.QName;
>   
> public class TestSpace {
> 	public static void main(String [] args) {
> 		try {
> 			String endpoint =
> 				"http://soap.4s4c.com/ilab/soap.asp";
> 			SimpleChain responseChain = new SimpleChain();
> 			responseChain.addHandler( new LogHandler() );
> 			responseChain.init();
> 			Service  service = new Service();
> 			Call     call    = (Call) service.createCall();
> 			
> 			call.setTargetEndpointAddress( new java.net.URL(endpoint) );
> 			call.setOperationName(new QName("http://soapinterop.org/", "echoString" ) );
> 			RPCParam param = new RPCParam( "inputString", "  Hello  " );
> 			String ret = (String) call.invoke( new Object[] { param } );
> 		
> 			System.out.println("Sent 'Hello!', got '" + ret + "'");
> 			Node result = call.getMessageContext().getResponseMessage().getSOAPBody().getFirstChild().getFirstChild().getFirstChild();
> 			System.out.println( "DOM Value: '" + result.getNodeValue() + "'" );
> 			
> 		} catch (Exception e) {
> 			System.err.println(e.toString());
> 		}
> 	}
> }
> This is an adapted version of the "Getting Started" sample found in the online documentation.  It calls a publically available echo service (the version in the online doc references a web service that is no longer running).  It calls a method "EchoString" that echoes the given string.
> The above sample asks the web service to echo a string with whitespace at the beginning and end of the string.  It then prints the result.  Finally, it goes into the DOM of the SOAP envelope and prints the text node value of the response string.  The above sample will show that the DOM implementation is improperly stripping the whitespace while the return value correctly preserves them.
> I spent a little time trying to track down this issue.  I believe the issue is in org.apache.axis.message.SoapHandler.addTextNode().  The issue is corrected by replacing:
> "String s = StringUtils.strip( val.toString() );"
> with:
> String s = val.toString()
> I know of nothing in any of the specifications that indicate that whitespace is not a valid textnode value, nor should be stripped (unless the schema type is xsd:normalizedString or xsd:token).
> I've reproduced this in Axis 1.2 and 1.4.
> Thank you.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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