2 Replies Latest reply on Apr 12, 2006 10:55 AM by Amit Mahale

    Uncompleted SOAPElement  by using Transformer.

    Yoshihide TOMIYAMA Newbie


      I'm trying to convert javax.xml.soap.SOAPElement into String with javax.xml.transform.Transformer class.
      However, I cannot get the complete XML document. The proceeded XML document by JBoss Transformer
      was lacked some information.

      [Development environment]
      IDE: eclipse 3.1.1
      SAAJ: JBoss 4.0.3SP1 (%JBOSS_HOME%/client)
      J2SDK: 1.4.2_10 (Sun)
      endorsed: Xerces & Xalan (%JBOSS_HOME%/lib/endorsed)

      import java.io.FileInputStream;
      import java.io.StringWriter;
      import javax.xml.soap.MessageFactory;
      import javax.xml.soap.MimeHeaders;
      import javax.xml.soap.SOAPBody;
      import javax.xml.soap.SOAPElement;
      import javax.xml.soap.SOAPMessage;
      import javax.xml.soap.SOAPPart;
      import javax.xml.transform.Transformer;
      import javax.xml.transform.TransformerFactory;
      import javax.xml.transform.dom.DOMSource;
      import javax.xml.transform.stream.StreamResult;
      public class TestSoapWriter {
       public static void main(String[] args) {
       try {
       MessageFactory mf = MessageFactory.newInstance();
       SOAPMessage msg = mf.createMessage(new MimeHeaders(),
       new FileInputStream("sample.xml"));
       SOAPPart sp = msg.getSOAPPart();
       SOAPBody sb = sp.getEnvelope().getBody();
       SOAPElement element = (SOAPElement) sb.getChildElements().next();
       TransformerFactory tf = TransformerFactory.newInstance();
       Transformer trans = tf.newTransformer();
       StringWriter sw = new StringWriter();
       trans.transform(new DOMSource(element), new StreamResult(sw));
       } catch (Exception e) {

      <?xml version="1.0" encoding="UTF-8"?>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <ns1:Order xmlns:ns1="http://ws.sample">

      <?xml version="1.0" encoding="UTF-8"?>
      <ns1:Order xmlns:ns1="http://ws.sample"><Customer>Kermit</Customer>

      The following part of XML document is lost by using JBoss Transformer.


      I tried it with SAAJ in axis1.2, and I can get the complete XML
      document, no lack of information.

      I am wondering if this is a JBoss issue....
      Or are there any solutions to this?

      I am appreciated any information to solve this issue!!