Hi,

I was able to get the whitespace problem solved. I am using Axis 1.1 which does 
not seem to have this parameter exposed. However I was able to change the axis 
code which sets pretty xml to false so this problem does not arise anymore and 
no extra whitespaces inserted in xml.

However, I am having another problem now. Axis when serializing messages, is 
removing prefix if there is default namespace. For example, if I have the 
following:

<wsu:Timestamp 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
 
wsu:Id="TrWh0UdhOBlayXdEr4JbRQ22"><wsu:Created>2005-12-05T22:39:47Z</wsu:Created></wsu:Timestamp>

And if I deserialize and serialize back, Axis gives me:

<Timestamp 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
 
wsu:Id="TrWh0UdhOBlayXdEr4JbRQ22"><Created>2005-12-05T22:39:47Z</Created></Timestamp>

This is causing problem because we are signing the timestamp element and then 
the verification is failing since the element has been modified when we remove 
the prefixes.

Is there any way to turn this off in Axis so Axis does not remove the prefix? 
Is this bug fixed in newer version of Axis? What are the solutions to solve 
this problem? 


-pratibha



-----Original Message-----
From: Davanum Srinivas [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 14, 2005 5:09 PM
To: axis-user@ws.apache.org
Subject: Re: axis SAAJ whitespace problem

Did you try the following in the global configuration section in Axis 1.1?

<parameter name="disablePrettyXML" value="true"/>

Am not sure if it was even implemented in the old version of Axis.

thanks,
dims

On 11/14/05, Pratibha Mittal <[EMAIL PROTECTED]> wrote:
> Hi Dims,
>
> Thanks for your reply. Do you know if this bug fix has been back ported to 
> axis 1.1 or if not, if it is possible to do that and if so how?
>
> -pratibha
>
> -----Original Message-----
> From: Davanum Srinivas [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 07, 2005 9:52 PM
> To: axis-user@ws.apache.org
> Cc: [EMAIL PROTECTED]
> Subject: Re: axis SAAJ whitespace problem
>
> Pratibha,
>
> Please upgrade to latest Axis 1.3. We've fixed this problem.
>
> thanks,
> dims
>
> On 11/7/05, Pratibha Mittal <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > Hi,
> >
> >
> >
> > We are using Axis SAAJ implementation (version 1.1 of axis). I seem to be
> > having problem when I am serializing the SOAP envelope object to byte
> > stream. It is putting extra whitespaces and line breaks. This is causing
> > problem in verification of message when a signed message comes.
> >
> >
> >
> > The scenario is like this:
> >
> >
> >
> > A web service client signs the soap BODY, and sends to the server. The
> > server mainpulates the SOAP header (does not touch the body) using SAAJ java
> > APIs. Then the server tries to verify the soap message. For verification,
> > when it retrives the soap message, axis needs to recreate the byte stream
> > from java SOAP Envelope object since the message has been modified. However
> > the message retrieved does not have the the exact same SOAP Body. It has
> > extra whitespaces and line breaks and hence the verification fails.
> >
> >
> >
> > I was able to isolate problem in a simple test example and I can see that
> > the body gets changed when axis recreates the byte stream.
> >
> >
> >
> > Is this an Axis bug? Is it fixed in later versions? Has anybody encountered
> > similar problem? What are the options I have to solve this problem? Could
> > anybody please reply.
> >
> >
> >
> > Attached is the test program I used which gives the problem.
> >
> >
> >
> > Thanks
> >
> > Pratibha Mittal
> >
> > Oracle Corporation
> >
> >
> >
> > ******************************************************************************
> >
> >
> >
> >     public static void test() {
> >
> >       String str0 = new String(
> >
> >       "<soap:Envelope
> > xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"; " +
> >
> >       "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"; " +
> >
> >
> > "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"; "
> > +
> >
> >
> > "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\";
> > " +
> >
> >
> > "soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\";>
> > \n" +
> >
> >         "<soap:Body>\n" +
> >
> >         "      <ns2:getTime
> > xmlns:ns2=\"urn:Test:GetTime\">\n" +
> >
> >         "         <format
> > xsi:type=\"xsd:String\">VALUE</format>\n" +
> >
> >         "      </ns2:getTime>\n" +
> >
> >         "</soap:Body>\n" +
> >
> >         "</soap:Envelope>");
> >
> >       byte[] b0 = str0.getBytes();
> >
> >       ByteArrayInputStream inputstream = new ByteArrayInputStream(b0);
> >
> >
> >       try {
> >
> >
> >
> >         Message message = new Message(inputstream, false, null);
> >
> >         ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
> >
> >         message.writeTo(outputStream);
> >
> >         byte[] b1 = outputStream.toByteArray();
> >
> >         writeByteArray(b1);
> >
> >
> >
> >         SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
> >
> >         SOAPHeader existingHeader = envelope.getHeader();
> >
> >         if(existingHeader != null) existingHeader.detachNode();
> >
> >         SOAPHeader newHeader = envelope.addHeader();
> >
> >
> >
> >         ByteArrayOutputStream outputStream2 = new ByteArrayOutputStream();
> >
> >
> >         message.writeTo(outputStream2);
> >
> >         byte[] b2 = outputStream2.toByteArray();
> >
> >         writeByteArray(b2);
> >
> >
> >
> >       } catch (Exception e) {
> >
> >         e.printStackTrace();
> >
> >       }
> >
> >     }
> >
> >
> >
> >     public static void writeByteArray(byte[] b) {
> >
> >
> >
> >       try {
> >
> >         long l = (new java.util.Date()).getTime();
> >
> >         String numStr = (new Long(l)).toString();
> >
> >         java.io.BufferedReader br = new java.io.BufferedReader(new
> > java.io.InputStreamReader(new java.io.ByteArrayInputStream(b)));
> >
> >         String str = br.readLine();
> >
> >         while(str != null) {
> >
> >             System.out.println(str);
> >
> >             str = br.readLine();
> >
> >         }
> >
> >
> >
> >       } catch (Exception e) {
> >
> >         e.printStackTrace();
> >
> >       }
> >
> >       System.out.println("\n");
> >
> >     }
> >
> >
> >
> >
> >
> >
>
>
> --
> Davanum Srinivas : http://wso2.com/blogs/
>
>


--
Davanum Srinivas : http://wso2.com/blogs/

Reply via email to