This is also possible. All that you require is to build an XMLStreamReader and 
pass it to the parse method from the factory of your top level class. Check my 
sample code below. I created a stream reader from a sample xml file, in your 
case you can figure out to pass a string having the xml. Loan request is a 
binding class.
 
DocumentBuilderFactory documentBuilderFactory = 
DocumentBuilderFactory.newInstance();

InputSource inputSource = new InputSource("xmldata/LnRq_Accept.xml"); 

Document document = 
documentBuilderFactory.newDocumentBuilder().parse(inputSource);

StringWriter sw = new StringWriter();

Transformer serializer = TransformerFactory.newInstance().newTransformer();

serializer.transform(new DOMSource(document), new StreamResult(sw));

XMLStreamReader reader = 
XMLInputFactory.newInstance().createXMLStreamReader(new 
ByteArrayInputStream(sw.toString().getBytes()));

LoanRequest lnReq = LoanRequest.Factory.parse(reader);

-----Original Message-----
From: Sudhir Sharma [mailto:[EMAIL PROTECTED]
Sent: 01 November 2007 04:34
To: [email protected]
Subject: RE: Serialize/Deserialize



Hi,

 

I am also facing the same problem. Can anyone help us out.

Any help will be appreciated. 

 

Thanks & Best Regards,

Sudhir Sharma


  _____  


From: ABBUHL Richard NL [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 31, 2007 4:43 PM
To: [email protected]
Subject: Serialize/Deserialize

 

Axis allows you to serialize an object into XML using a SerializationContext.  
For example,

 

   // serialize the object

  StringWriter strWriter = new StringWriter();

  SerializationContext ctx = new SerializationContext(strWriter, 
MessageContext.getCurrentContext());

  ctx.serialize(new QName("MyObjectNamespace",  "MyObject"), null, myObject, 
null, Boolean.FALSE, Boolean.FALSE);

  String value = strWriter.toString();

 

Is it possible to use Axis to deserialize this string back into an object of 
type MyObject?  If so, can you please provide an example?

 

Regards,
Richard

 

-----------------------------------------------------------------------------------------------------------
This message is intended for the addressee or its representative only. Any form 
of unauthorized use, publication, reproduction, copying or disclosure of the 
content of this e-mail is not permitted. If you are not the intended recipient 
of this e-mail message and its contents, please notify the sender immediately 
and delete this message and all its attachments subsequently.

Reply via email to