axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David L. Brown" <>
Subject Controlling serialization
Date Mon, 13 Feb 2006 16:51:26 GMT
Is there a way to control the XML serialization of a SOAPMessage?  I'm 
using Axis for Java 1.2.

If I input a SOAP message that is all on one line, parse it, add a 
header, then serialize it, the message has new whitespace in it (tabs 
and carriage returns).  How can I stop it from generating this new 

For example for the code that follows ...
    private static void runTest1 () throws Exception
        System.out.println ("Test #1 ...\n");

        SOAPMessage message = loadMessageText (messageText1);
        SOAPHeader header = message.getSOAPHeader();
        SOAPHeaderElement headerElement = new SOAPHeaderElement 
("http://localhost", "testy");

        message.writeTo (System.out);

        System.out.println ("\n");

    private static SOAPMessage loadMessageText (String messageText)
            throws Exception
        MessageFactory messageFactory = MessageFactory.newInstance ();
        SOAPMessage message = messageFactory.createMessage (new 
MimeHeaders (),
                new ByteArrayInputStream (messageText.getBytes ()));
        return message;

where messageText1 equals the following ...

<?xml version="1.0" encoding="UTF-8"?><SOAP:Envelope 
xmlns="http://localhost:8080/test/services/Text"><in0 xmlns="">This is 
the message to echo</in0></echo></SOAP-ENV:Body></SOAP:Envelope>

My output is

<SOAP:Envelope xmlns:SOAP="">
  <ns1:testy SOAP:mustUnderstand="0" xmlns:ns1="http://localhost"/>
  <ns2:echo xmlns:ns2="http://localhost:8080/test/services/Text">
   <in0 xmlns="">This is a clean word:  unclassified</in0>

View raw message