You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "C.C. Ang" <ch...@utiba.com> on 2005/03/10 00:16:55 UTC

Receiving multiple parameters using Java

Hi there all,
I am a SOAP and AXIS newbie (3 days old) and had a question re
returning multiple parameters using java.
I have looked in the archives and cannot find anything that resolves
my question. So my conclusion is that I must be missing something
simple. 8-)

I have written a SOAP server written in python which takes in
3 parameters (Code, Timestamp and Misc) and returns these 3 parameters
as well as an additional parameter "Status".

The SOAP XML sent back looks like the following.
'''
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<MyRequestResponse SOAP-ENC:root="1">
<Result>
<Code xsi:type="xsd:string">Hello</LocalOPCode>
<Status xsi:type="xsd:string">success</Status>
<Misc xsi:type="xsd:string">one</LocalTAX>
<Timestmap xsi:type="xsd:string">two</BridgeTNXNo>
</Result>
</MyRequestResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
'''

My java client written using axis1.2RC3, snippet follows....
All it does is calls invoke and prints out the returned
result, which seems to be an array.

'''
call.addParameter("Code",
                  org.apache.axis.Constants.XSD_STRING,
                  javax.xml.rpc.ParameterMode.IN);
/* ... more of the same ... */
call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_ARRAY );

Object[] ret = (Object[])call.invoke( new Object[]{"Hello", "one", "two" );

for ( int i = 0; i < ret.length; i++ ) {
    System.out.println( "Sent 'Hello!', got '" + ret[i] + "'" );
}

'''

>From the client, it seems like call.invoke() returns an array.

My results are
Sent 'Hello!', got 'Hello'
Sent 'Hello!', got 'success'
Sent 'Hello!', got 'one'
Sent 'Hello!', got 'two'

I need to be able to distinguish which parameter is the
"Status" parameter. This information is lost cos the
client gets back the results in an array.

I need it to be in a Map (HashMap) or something like that
or a class?
Something which will allow to find out the value of Status.

Any suggestions as to how I can do this?

I could use something like jdom to unmarshall the XML
but thought AXIS might have something that would be similar.

Many thanks in advance,
Chai
-- 
| O! it is excellent! To have a giant's strength, but it is
| tyrannous! To use it like a giant. - William Shakespeare

-----------------
Utiba Pty Ltd 
This message has been scanned for viruses and
dangerous content by Utiba mail server and is 
believed to be clean.