You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Michael Thome <mt...@bbn.com> on 2006/08/31 19:34:20 UTC

Deserialization of message from file problem

I'm having trouble deserializing messages from a file (or other stream): 
I can serialize just fine with the following pattern:
       MessageContext msgContext = new MessageContext(new AxisServer());
       msgContext.setEncodingStyle(Constants.URI_LITERAL_ENC);
       SOAPEnvelope msg = new SOAPEnvelope();
       SOAPBodyElement body = new SOAPBodyElement(theQname, theObject);
       msg.addBodyElement(body);
       SerializationContext context = new SerializationContext(new 
FileWriter(myfilename), msgContext);
       msg.output(context);

In the other direction, I'm using:
       MessageContext msgContext = new MessageContext(new AxisServer());
       msgContext.setEncodingStyle(Constants.URI_LITERAL_ENC);
       String buf = readMyFile();
       Message message = new Message(buf);
       message.setMessageContext(msgContext);
       SOAPEnvelope envelope = message.getSOAPEnvelope();
       RPCElement body = (RPCElement) envelope.getFirstBody();
       Vector arglist = body.getParams();  // ***
       RPCParam param = (RPCParam) arglist.get(0);
       Object theObject = param.getObjectValue();
But, I get an exception on the getParams complaining about an invalid 
element.  I'm guessing that I need to change something in my 
deserialization methodology.  While I'm not thrilled by the xml that is 
emitted during serialization (specifically, that many elements have what 
appears to me to me redundant xsi:type attributes), the content looks 
like it ought to be read back in correctly.  I'm not posting any schema 
or xml here because I see the same problems regardless of what I'm 
(de)serializing (always wsdl2java objects defined as complexType).

Any suggestions would be welcome,

Thanks
-- 
*Michael Thome*
BBN Technologies 10 Moulton St, Cambridge MA 02138 USA
phone: +1 617 873 1853


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org