You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Kerber <dc...@verizon.net> on 2006/03/15 14:45:41 UTC

Trouble parsing SOAP return value

I have an Apache SOAP server set up in tomcat, the server side works 
fine, and I can see through the Eclipse TCP/IP monitor that it is 
returning the correct data.  What I can't figure out is how to parse out 
the simple Integer[] array when it gets back to the client.  I've been 
googling and reading documentation for two days, and am still drawing a 
blank, so I'm asking for help here. 

Below are listed some code excerpts, the Descriptor and SOAP request and 
response packets.  You can see that the response is a simple array of 
integers, but I continually get ClassCastExceptions when I try to read 
out the data at the end.  I'm guessing it's just some stupid little 
thing I'm missing, but I sure can't see it, and any suggestions will be 
greatly appreciated!!

This is the applicable piece of the client code.  The stuff that is 
commented out is stuff I've tried and which failed to work:

        Response resp = call.invoke(url, "" );
        if ( resp.generatedFault() ) {
            System.out.println( "The call failed: " );
        } else {
            Parameter result = resp.getReturnValue();
//            Integer[] result = resp.getReturnValue();
           
            System.out.println( "Rtn val = " + result.getValue());
            System.out.println( "resp Object type: " + result.getClass());
            System.out.println( "resp Object toString: " + 
result.toString());
//            Integer[] rtnValues = ( Integer[] ) result.getValue(  );
            EddSrvResponse rtnValues = ( EddSrvResponse ) result.getValue();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is where I get the ClassCastExecption.

/*            for ( ii = 0; ii < rtnValues.length; ii++ )
                System.out.println( rtnValues[ ii ]);       
            }
*/
            System.out.println( "XID   :  " + rtnValues.getXID() );
            System.out.println( "Status:  " + rtnValues.getStatus() );

//            Integer r = (Integer) result.getValue();
//            System.out.println( "Xid:" + r);
           
//            System.out.println( result[0] );



EddSrvResponse is defined as:
public class EddSrvResponse {
    private Integer    xID;
    private Integer    status;
and has appropriate setters and getters which I won't bother to list here.



The Descriptor:

<?xml version="1.0" encoding="UTF-8"?>
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
    id="urn:wraEddServer">
        <isd:provider type="java"
            scope="Application"
            methods="getDataLine">
            <isd:java class="eddSrv.getDataLine"/>
        </isd:provider>
    
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
</isd:service>


The SOAP request:

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getDataLine xmlns:ns1="urn:wraEddServer" 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<XID xsi:type="xsd:string">11</XID>
<Site xsi:type="xsd:string">22</Site>
<Time xsi:type="xsd:string">Wed Mar 15 08:28:26 EST 2006</Time>
<Data xsi:type="xsd:string">44</Data>
</ns1:getDataLine>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


The SOAP response:

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getDataLineResponse xmlns:ns1="urn:wraEddServer" 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" 
xsi:type="ns2:Array" ns2:arrayType="xsd:int[2]">
<item xsi:type="xsd:int">11</item>
<item xsi:type="xsd:int">0</item>
</return>
</ns1:getDataLineResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Thanks for any help!
Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org