Hi Wei,

There is an AxisUtil class in wss4j  jar.  However that didn't appear to contain the methods named so I just copied the required methods in to my own class.  

Aoife



wei zhu <[EMAIL PROTECTED]>

19/07/2004 23:41
Please respond to axis-user

       
        To:        [EMAIL PROTECTED]
        cc:        
        Subject:        Re: Deseralize XML



Yves,
I couldn't find java class AxisUtil. Do you know which jar AxisUtil is in?
 
thanks a lot
Wei
 
 
///////////////////////////////////////////////////////////////////////////////////////
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
> >


Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!

Reply via email to