Link to home
Create AccountLog in
Avatar of blackfrancis75
blackfrancis75

asked on

Axis : SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.

I have written an Axis  Soap client using WSDL2Java generated types thus:

      DataServiceLocator locator = new DataServiceLocator();      

      Call call = (Call) locator.createCall();
      call.setTargetEndpointAddress( endpoint );
      call.setOperationName( new QName("getById") );
      call.addParameter("in0", XMLType.SOAP_ARRAY, ParameterMode.INOUT);
      call.setReturnType(XMLType.SOAP_STRING);
      locator.getEngine().setOption("sendMultiRefs", Boolean.FALSE);
      
      call.invoke(new Object[]{ new int[]{29491907} });

This works as far as retrieving the desired data (which I see by means of a packet sniffer), but while deserializing the response (which I dont explicitly ask it to do) I get:

org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
      at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
      at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
      at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)

From my brief googling, I'm currently thinking I need to do something along the lines of:

      TypeMapping tm = locator.getTypeMappingRegistry().createTypeMapping();
      locator.getTypeMappingRegistry().register("http://schemas.xmlsoap.org/soap/encoding/", tm );

But I'm just stabbing in the dark; can someone tell me how to enable the deserialization?
Cheers,
Avatar of blackfrancis75
blackfrancis75

ASKER

Hmm, I have changed call.setReturnType(XMLType.SOAP_STRING);
to call.setReturnType(XMLType.SOAP_ARRAY);
(doh!)

now I get:
org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType

I guess I explicitly have to register a dezerializer somehow?
wsdl attached
example.txt
ASKER CERTIFIED SOLUTION
Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account