You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Kent Tong <ke...@cpttm.org.mo> on 2004/12/06 06:13:18 UTC

SOAPPart setContent adds newlines

Hi,

As an experiment, I have written a client handler that is
like:

    public void invoke(MessageContext msgContext) throws AxisFault {
       SOAPMessage msg = msgContext.getMessage();
       SOAPEnvelope env = (SOAPEnvelope) msg.getSOAPPart().getEnvelope();
       Document doc = env.getAsDocument();
       DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();
       factory.setNamespaceAware(true);
       //msgContext.getMessage().getSOAPPart().setContent(
       //    new DOMSource(doc));
       msg = msgContext.getMessage();
       msg.writeTo(System.out);
     }

The output is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
   <ns1:concat 
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:ns1="urn:mo.org.cpttm.stringservice">
    <ns1:arg0 xsi:type="xsd:string">abc</ns1:arg0>
    <ns1:arg1 xsi:type="xsd:string">def</ns1:arg1>
   </ns1:concat>
  </soapenv:Body>
</soapenv:Envelope>

If I uncomment the line, then the output becomes:

<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soapenv:Body>

     <ns1:concat 
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:ns1="urn:mo.org.cpttm.stringservice">

       <ns1:arg0 xsi:type="xsd:string">
abc   </ns1:arg0>

       <ns1:arg1 xsi:type="xsd:string">
def   </ns1:arg1>

     </ns1:concat>

   </soapenv:Body>

</soapenv:Envelope>

That is, it adds a lot of newlines and spaces. It even changes
the argument of the soap call from "abc" to "abc   ". Any idea?

Thanks!