You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Pankaj Kharwal <Pa...@kf.se> on 2011/11/30 11:49:45 UTC

Problem with AXIOM Handling of Newlines and Spaces in SOAP requests

Hi All,

I am using AXIS2C version 1.6.0 on an X86 64-bit  Redhat machine. I use soapUI for sending requests and AXIS2C receives newlines and spaces in the request which I cannot control from the request part.

For example, My soapUI request looks like:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://ws.apache.org/axis2/services/Calculator/types">
   <soapenv:Header/>
   <soapenv:Body>
      <typ:add xmlns:typ = 'http://example.com/add/2010/11/policy'>
        <param_1>11</param_1>
        <param_2>22</param_2>
      </typ:add>
   </soapenv:Body>
</soapenv:Envelope>

Here, axiom_node_to_string() function for <add> node yields  "<typ:add xmlns:typ = 'http://example.com/add/2010/11/policy'>\n        <param_1>11</param_1>\n        <param_2>22</param_2>\n      </typ:add>"
I thought I will first convert this node to a buffer (addBuf); then I will process this buffer to remove newlines; and then I will pass the processed buffer to axiom_xml_reader_create_for_memory().

So the sequence of my calls is:

reader = axiom_xml_reader_create_for_memory(env,  (void*)addBuf, axutil_strlen(addBuf), "utf-8", AXIS2_XML_PARSER_TYPE_BUFFER);
builder = axiom_stax_builder_create(env, reader);
document = axiom_stax_builder_get_document(builder, env);
processedAddNode = axiom_document_get_root_element(document, env);

My observations:

1.       CASE1: addBuf is passed as it is (with newlines and spaces) to axiom_xml_reader_create_for_memory. The call to axiom_xml_reader_create_for_memory() is successful; but the processedAddNode does not have <param_1> and <param_2> tags.



2.       CASE2: Before calling axiom_xml_reader_create_for_memory, I process addBuf just to remove newlines. addBuf looks like "<typ:add xmlns:typ = 'http://example.com/add/2010/11/policy'>        <param_1>11</param_1>        <param_2>22</param_2>      </typ:add>". The spaces that existed after the newlines, still remain there. Here also, the call to axiom_xml_reader_create_for_memory() is successful; but the processedAddNode does not have <param_1> and <param_2> tags.



3.       CASE3: I hardcoded addBuf to "<typ:add xmlns:typ = 'http://example.com/add/2010/11/policy'><param_1>11</param_1><param_2>22</param_2></typ:add>".  Note that the newlines are removed and spaces after the newlines were also removed. This time call to axiom_xml_reader_create_for_memory() was successful. processedAddNode was perfect.

So, if there are any spaces after the ending tags, AXIOM does not seem to handle them very well. Of course, I can process the buffer to remove these obsolete spaces as well, but I have a gut feeling that AXIOM must have some efficient mechanism, which I am not aware of as of now, to handle this situation.

I would be really thankful if you could provide me any ideas on implementing better mechanisms for this.

Best Regards,
Pankaj Kharwal
Stockholm, Sweden

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________