You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by nb...@touchcorp.com on 2002/09/20 06:16:52 UTC

Bugs #12753 and #12636 - proposed solution

Hi Developer-guys,

I have had the exact same problem as both of these bugs, but with
complex types.

My error trace looks like this:

org.xml.sax.SAXException: Bad types (class
com.touchcorp.soap.ihire.THireInfo -> class java.lang.String)
        at
org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:273)
        at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Deseria
lizationContextImpl.java:883)
        at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:
158)
        at
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.j
ava:681)
        at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:244)
        at
org.apache.axis.message.RPCElement.getParams(RPCElement.java:268)
        at org.apache.axis.client.Call.invoke(Call.java:1862)
        at org.apache.axis.client.Call.invoke(Call.java:1768)
        at org.apache.axis.client.Call.invoke(Call.java:1306)
        at
com.touchcorp.soap.ihire.IHirebindingStub.getHireFromCustomerLicence(IHi
rebindingStub.java:257)
        at
com.touchcorp.remote.party.MystHireService.getHireFromCustomerLicence(My
stHireService.java:141)
        at
com.touchcorp.remote.party.MystHireService.main(MystHireService.java:188
)
[ERROR] Call - -Exception: <org.xml.sax.SAXException: Bad types (class
com.touchcorp.soap.ihire.THireInfo -> class java.lang.String)>
Exception in thread "main" AxisFault
 faultCode: {http://xml.apache.org/axis/}Server.userException
 faultString: org.xml.sax.SAXException: Bad types (class
com.touchcorp.soap.ihire.THireInfo -> class java.lang.String)
 faultActor: null
 faultDetail:
        stackTrace: org.xml.sax.SAXException: Bad types (class
com.touchcorp.soap.ihire.THireInfo -&gt; class java.lang.String)
...
(goes FOREVER)

Looking at the code in
org.apache.axis.message.RPCHandler.onStartChild(), it looks to me like
(just maybe) it's trying a bit too hard.  

The section that's failing appears to be trying to head off a possible
deserialization problem by checking that source and destination types
are actually convertible.   While this appears to be an appropriate
action, you have to ask, "Why?  What would happen if we didn't do this
check?"  If the deserialization actually is impossible, we'll throw an
exception then.  This piece of code seems (to me, again, with respect)
to be totally superfluous PLUS it means that you have to maintain
JavaUtils.isConvertable() as well.

So I removed lines 267 to 277:
              if (paramDesc != null && paramDesc.getJavaType() != null)
{
                  // If we have an xsi:type, make sure it makes sense
                  // with the current paramDesc type
                  Class xsiClass = 
 
context.getTypeMapping().getClassForQName(type);
                  if (!JavaUtils.isConvertable(xsiClass, destClass)) {
                  System.out.println("dser = " +
dser.getClass().getName());
                      throw new SAXException("Bad types (" +
                                             xsiClass + " -> " +
destClass + ")"); // FIXME!
                  }
              }

And now it works for me.

My complex object "com.touchcorp.soap.ihire.THireInfo" is handled by the
BeanSerializer and my client now works totally happily.  

Hope this is useful to you.

Regards,

Neil Brennan

P.S. Even if you decide to keep the code - a *SAX* exception?  What?
How do you arrive at that?  It really has nothing to do with the XML at
this stage, does it?