axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Theroux (JIRA)" <axis-...@ws.apache.org>
Subject [jira] Created: (AXIS-2633) The Axis DOM implementation is improperly stripping whitespace from the beginning and end of Text nodes
Date Tue, 27 Feb 2007 13:23:05 GMT
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
             Fix For: 1.2, 1.2.1, 1.3, 1.4


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.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message