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/