Hi!
When invoking a method from the client, it's
possible to get the following error if type mappings have not been
registered:
"SimpleDeserializer encountered
a child element, which is NOT expected, in something it was trying to
deserialize."
This is solved by calling registerTypeMapping()
against the org.apache.axis.client.Call object
BUT ONLY if you know what to pass as parameters!
From the JavaDoc, the second parameter for
registerTypeMapping() is called xmlType and is defined to be:
"the xsi:type QName of the associated XML type"
which, while being correct, is incomplete (or
misleading for simple folks like me).
Similarly, the WSDD documentation for:
<typeMapping
qname="ns:localName" classname="classname" serializer="classname"
deserializer="classname"/>
namely:
"Each typeMapping maps an XML qualified name to/from a
Java class, using a specified Serializer and Deserializer."
while being more ambiguous and, paradoxically, more
comprehensive, is, nonetheless, still far from illuminating!
Examining that part of
org.apache.axis.client.Call.invoke() that makes use of type mappings,
namely:
dser =
context.getDeserializerForType(qname);
in:
org.apache.axis.message.RPCHandler.onStartChild()
it is apparent that a match is sought for an XML
element name, not an XML type name. (Of course, some folks might argue that
elements are types but, while that isn't an unreasonable stance, it is
certainly confusing when dealing with XML Schema.)
Unfortunately, I had been supplying an XML Schema
complex type name rather than an element name to registerTypeMapping() and
getting the "SimpleDeserializer encountered a child element..."
error.
In my case, this is wrong:
call.registerTypeMapping(net.opengis.www.sensorML.SensorType.class, new
javax.xml.namespace.QName("http://www.opengis.net/sensorML",
"SensorType"), beansf, beandf);
and this is right:
call.registerTypeMapping(net.opengis.www.sensorML.SensorType.class, new
javax.xml.namespace.QName("http://www.opengis.net/sensorML",
"Sensor"), beansf, beandf);
Since the class DescribeSensorResponseType,
which aggregates a SensorType object, was generated by WSDL2Java and contains
the Sensor/SensorType mapping, vis:
org.apache.axis.description.ElementDesc elemField = new
org.apache.axis.description.ElementDesc();
elemField.setFieldName("sensor"); elemField.setXmlName(new javax.xml.namespace.QName("http://www.opengis.net/sensorML", "Sensor")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.opengis.net/sensorML", "SensorType")); typeDesc.addFieldDesc(elemField); I had been under the illusion that
org.apache.axis.client.Call could make the association and it didn't occur to me
to use "Sensor" rather than "SensorType" in registerTypeMapping().
I shall be grateful if the
registerTypeMapping() JavaDoc could be updated to something like:
xmlType - the xsi:type QName of
the associated XML type or, in the case of complex types, the QName of the
associated XML element.
I shall also be grateful if someone could point me
to where this is documented, if it is; that way I might not be so dumb in
the future!
Warmest regards,
Jeff Lawson
Cogent Logic Corporation
Toronto, Canada
|