Hi Michael,
Once again thanks for your help.
Do not get confused by the next words: The fact that one has to specify the
class when deserialising was no problem for us, because we have some kind of
a top level 'ResponseType' XML element. All responses are of this type,
even if they look pretty different internally.
This class parameter could be of a problem if you do not have a common root element in you XML, since then you had to pass for each XML to be deserialised the right and corresponding class instance (but with a little help from reflection even that is not extremely advanced).
It will not be a problem for us either. This transformation XML -> Datatype is carried out prior to invoking a web service. Because we have a very large number of web service operations which can change regularly we use a XSL stylesheet along with an XML file (This XML file is generated based on the WSDL file and it contains a list of each web service operation names, its argument types, return types and their corresponding class names) to generate the source code for invoking our web services. The transformation produces a source file which includes an anonymous inner class for each web service operation to be invoked and the inner class is stored in a HashMap keyed on the name of the operation. The name of the operation can then been retrieved from the root element within our XML message (similar to they way you do it) and used to look up the appropriate inner class to be invoked. What all this means is that our anonymous inner class which will be responsible for doing the XML deserialization can be genereted so that it can contain the appropriate class name which can be passed to a method similar to your xmlToAxis method.
Hope that makes some sense :)
Tom
From: "Michael Binz" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] Subject: RE: Deserializing XML w/o using client stubs Date: Wed, 29 Sep 2004 17:24:17 +0200 (MEST)
Tom,
> Yes we are going to work with generated stubs. All Im > confused about now is > what Axis1.2 offers that supercedes the need to manually > register the datat > type class (i.e. will mean that I dont have to use reflection > to instantiate > the stub for my dataclass and then retrive the TypeDesc from > the stub and > register this TypeDesc with the TypeMapping object which > exists within the > MessageContext).
Sorry, it was not my goal to confuse you ;^)
> > You said " What you get there is a readily initialised > TypeMapping, so you > don't need to > manually register the classes." > > Where does this readily initialised TypeMapping exist and > what is the new > magic that means that I dont have to manually do the registration.
The answer is in the method xmlToAxis() in the code that you got. First on
Axis 1.2 the call to registerAxisClassesInContext() is not longer necessary,
the context has internally seemingly that 'readily initialised TypeMapping'
and can parse the XML.
Below that you will find:
// On Axis 1.2 use the getValueAsType( qname, class ) in the next // line and not the single arg version. //return rpcElem.getValueAsType(qname, clazz); return rpcElem.getValueAsType( pQname ); // Axis 1.1 code.
The commented line 'getValueAsType(qname, clazz)' is also Axis 1.2 magic:
You pass the class that you expect the returned object to be an instance of.
As as side note, this makes it necessary that the generated classes are in
the classpath.
If the transform is not possible this call will fail.
Axis 1.2 is internally able to identify the required TypeMapping and so on, you as a user of the interface do not have to think at all about that magic behind the scenes. So that 'readily initialised TypeMapping' seems to be there, but doesn't impact you.
Do not get confused by the next words: The fact that one has to specify the
class when deserialising was no problem for us, because we have some kind of
a top level 'ResponseType' XML element. All responses are of this type,
even if they look pretty different internally.
This class parameter could be of a problem if you do not have a common root element in you XML, since then you had to pass for each XML to be deserialised the right and corresponding class instance (but with a little help from reflection even that is not extremely advanced).
Hope that helps. Michael.
-- +++ GMX DSL Premiumtarife 3 Monate gratis* + WLAN-Router 0,- EUR* +++ Clevere DSL-Nutzer wechseln jetzt zu GMX: http://www.gmx.net/de/go/dsl
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail