Check the list. For example:
Tom, Noel, Aoife,
Try this with 1.2beta:
/** * Deserializes an InputStream (i.e. a XML file) to the appropriate Java Class * generated by Axis. * * @param is is the InputStream for deserializing (without SOAP elements) * @param qname is the qualified name of the namespace of the XML Type of clazz * @param clazz is the Java Type representation of the XML stream is * @return Object which has to be casted to the specified Java Class (clazz) * @throws Exception * @throws AxisFault */ public static Object deserializeFromInputStream(InputStream is, QName qname, Class clazz) throws Exception, AxisFault {
// Wrap the InputStream up into a SOAP Body and Envelope since the parser // expects a SOAP Envelope SOAPEnvelope env1 = new SOAPEnvelope(); env1.addBodyElement(new SOAPBodyElement(is));
return AxisUtil.deserializeFromSOAPReader(new BufferedReader(new StringReader(env1.toString())), qname, clazz); }
/**
* Deserializes a SOAP Reader (i.e. a XML file) to the appropriate
Java Class
* generated by Axis.
*
* @param reader is the Reader for deserializing (a SOAP envelope)
* @param qname is the qualified name of the namespace of the XML Type
of clazz * @param clazz is the Java Type representation of the XML stream is
* @return Object which has to be casted to the specified Java Class
(clazz)
* @throws Exception
* @throws AxisFault
*/
public static Object deserializeFromSOAPReader(Reader reader, QName
qname, Class clazz) throws Exception, AxisFault {
MessageContext msgContext = new MessageContext(new AxisServer());
DeserializationContext dser = new DeserializationContextImpl( new InputSource(reader), msgContext, org.apache.axis.Message.REQUEST);
// parse the InputSource dser.parse();
SOAPEnvelope env = dser.getEnvelope(); RPCElement rpcElem = (RPCElement)env.getFirstBody(); Object result = rpcElem.getValueAsType(qname, clazz); return result; }
Regards, Yves
On Thu, 2004-07-15 at 11:58, [EMAIL PROTECTED] wrote:
Hi, This is exactly what I need also. Has anybody found a solution for this? Thanks, Aoife
>Hi, >I've been looking to do the same thing. If I can find out how to call
the axis
>serialize / deserialize routines by hand, I can do away with using
castor -
>which to be honest is a bit of a pain to integrate with axis. > >So, please, anyone got an answer for this? >ta >Noel
On Thursday 06 November 2003 08:54, tom ONeill wrote:
> Hi all, > > Some existing mails seem to touch on this subject but Im still not
clear on
> the issue so here goes. > I have used wsdl2java to create my stubs and also a number of
complex types
> defined within the wsdl file. > > Before I invoke my web service I am receiving an XML stream, the
structure
> of which I want to map directly to a data class that I am passing as
a
> parameter to the web service operation call. What I am wondering is
if Axis
> has some method of allowing me to marshall this XML into the
corresponding
> data class/Bean. I cannot seem to find a method within the
Deserializer API
> that would allow me to do this. > > All help appreciated, > > Tom > > _________________________________________________________________ > Crave some Miles Davis or Grateful Dead? Your old favorites are
always
> playing on MSN Radio Plus. Trial month free! > http://join.msn.com/?page=offers/premiumradio
Levy, Avi wrote:
This helps. Thanks.
However, I'm stil vage on how to deserialize XML into java objects (predefined classes).
Thanks,
-- AV
-----Original Message-----
From: toby cabot [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 23, 2004 8:19 AM
To: [EMAIL PROTECTED]
Subject: Re: Using a serializer and deserializer
Don't know about any docs or tutorials but something like...
void axisSerialize(Object report, Writer whereTo) throws IOException { SerializationContext ser = new SerializationContext(whereTo); ser.setPretty(true); ser.setSendDecl(true);
AttributesImpl ns = new AttributesImpl(); // add attributes here
ser.serialize(new QName("elementName"), ns, report, null, Boolean.FALSE, Boolean.FALSE); whereTo.flush(); }
... should get you pretty close. Make sure that you're using the latest and greatest Axis as there have been a few bugs fixed recently.