Hi.

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));
  | 
  |             System.out.println(sw);
  |         } catch (Exception e) {
  |             e.printStackTrace();
  |         }
  |     }
  | 
  | }

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

<?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. 

"<Item>Ferrari</Item></ns1:Order>"

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!!

Yoshihide

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3917553#3917553

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3917553


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to