axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject WSDL2Java and document/literal
Date Fri, 27 Aug 2004 10:00:10 GMT

I have some WSDL that defines a service which takes no parameters but 
which has a complex response object. The response object defines a list of 
complex objects (which are not very complex in reality, with each object 
having a few attributes of strings and ints). The WSDL2Java tool generates 
all of the classes just fine, but there is nothing done to the incoming 
response, which comes back as a raw XML SOAP body element. There is no 
code that converts the response element to the list object that I want. 
All the generated stub does is try to cast the response element (actually 
a vector of soap body elements, with only one entry) to the class that was 
generated for the response message. Consequently, a class cast exception 

Does anyone have any ideas what I might need to do, to get this to work, 
other than write some XML parsing code?

Just to clarify ...

The response from the service call is a vector of RPCElement instances (an 
Axis class). There is only one element in the vector, as expected. The 
single element, an RPCElement, is the XML of the expected response. The 
XML defines a list of other elements, each of which has a few simple 
attributes. The relevant generated stub code looks something like this:

        java.lang.Object _resp = _call.invoke(new java.lang.Object[] 

        if (_resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException)_resp;
        else {
            try {
                return (myResponseClass) _resp;
            } catch (java.lang.Exception _exception) {
                return (myResponseClass) 
org.apache.axis.utils.JavaUtils.convert(_resp, myResponseClass);

The _resp object is the vector of RPCElements. The myReponseClass is the 
class generated from my WSDL response message definition. The cast is 
always bound to fail, and the JavaUtils.convert call is only designed to 
convert between collections (which my response message class isn't). I 
feel sure that I'm not doing something I need to, since  can't see how 
this could ever work for anyone.

I tried the generator that comes with Sun's JWSDK and this seems to work 
OK, though I haven't delved into the innards yet, so don't know what the 
differences are.

View raw message