users@jax-rpc.java.net

Re: Return an array of objects

From: Mariano Garcia <mgarcia_at_entel.es>
Date: Wed, 07 Sep 2005 13:06:03 +0200

mmmm

I think I have forgotten something. Some of my steps must be wrong. You
are using a class named ReturnWeb_AdminResellerListNewsCentres in your
code. Has this class been generated from wsdl? or have you coded it?

Maybe my problem is that when I use wscompile to generate java code from
wsdl file I am not getting classes for Array Objects defined in WSDL
file. Should WSDL->JAVA tools generate java class files for each type
define in WSDL file?

Maybe it is a nonsense :), I am very newbie.

On Wed, 2005-09-07 at 03:38 -0700, trebor iksrazal wrote:
> > So, my question is how I have to contruct this
> > message from server side.
>
> Its a bit tricky the first time, but perhaps looking
> at an example of how I do it may help:
>
> <complexType name="ReturnWeb_Base">
> <sequence>
> <element name="errorMessage" type="string"/>
> <element name="successErrorCode"
> type="int"/></sequence></complexType>
>
> This is nessecary in my example because all methods
> return an error code/message to indicate
> success/failure.
>
> <complexType
> name="ReturnWeb_AdminResellerListNewsCentres">
> <complexContent>
> <extension base="tns:ReturnWeb_Base">
> <sequence>
> <element name="list"
> type="tns:ArrayOfReturnWeb_AdminResellerListNewsCentres_Item"/></sequence></extension></complex
> Content></complexType>
> <complexType
> name="ArrayOfReturnWeb_AdminResellerListNewsCentres_Item">
> <complexContent>
> <restriction base="soap11-enc:Array">
> <attribute ref="soap11-enc:arrayType"
> wsdl:arrayType="tns:ReturnWeb_AdminResellerListNewsCentres_Item[]"/></restrictio
> n></complexContent></complexType>
> <complexType
> name="ReturnWeb_AdminResellerListNewsCentres_Item">
> <sequence>
> <element name="news_id" type="int"/>
> <element name="call_centre_id" type="int"/>
> <element name="call_centre_name"
> type="string"/></sequence></complexType>
>
> So what this says is my complex object extends
> 'ReturnWeb_Base' - hopefully not confusing you, see
> below, and the web service returns
> ReturnWeb_AdminResellerListNewsCentres .
>
> To complete the wsdl we have:
>
> <message
> name="CallCentreWebEndpoint_web_adminreseller_ListNewsCentres">
> <part name="soap_session_id" type="xsd:string"/>
> </message>
> <message
> name="CallCentreWebEndpoint_web_adminreseller_ListNewsCentresResponse">
> <part name="result"
> type="ns2:ReturnWeb_AdminResellerListNewsCentres"/>
> </message>
>
> <operation name="web_adminreseller_ListNewsCentres"
> parameterOrder="soap_session_id">
> <input
> message="tns:CallCentreWebEndpoint_web_adminreseller_ListNewsCentres"/>
> <output
> message="tns:CallCentreWebEndpoint_web_adminreseller_ListNewsCentresResponse"/>
> </operation>
>
> <operation name="web_adminreseller_ListNewsCentres">
> <soap:operation soapAction=""/>
> <input>
> <soap:body
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> use="encoded"
> namespace="http://localhost/callcentreweb"/></input>
> <output>
> <soap:body
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> use="encoded"
> namespace="http://localhost/callcentreweb"/></output></operation>
>
> The web service method signature is:
>
> public ReturnWeb_AdminResellerListNewsCentres
> web_adminreseller_ListNewsCentres(
> String soap_session_id) throws
> RemoteException {
> ReturnWeb_AdminResellerListNewsCentres result = null;
>
> result =
> MyDAODelegate.web_adminreseller_ListNewsCentres(params);
>
>
>
> } catch(Exception ex) {
> result = new
> ReturnWeb_AdminResellerListNewsCentres();
>
> result.setErrorMessage(Messages_Codes.getcode(Messages_Codes.FAILURE.intValue()));
> return result;
> }
>
> return result;
> }
>
> Ignore the soap_session_id - its not relevent here.
> Hand coded of course.
>
> Now, the delegate converts list to array as follows:
>
> ReturnWeb_AdminResellerListNewsCentres result = new
> ReturnWeb_AdminResellerListNewsCentres();
> int ret =
> Messages_Codes.FAILURE.intValue();
> ArrayList list = new ArrayList();
> list.add(item1);
> list.add(item2);
> list.add(item3);
>
> ReturnWeb_AdminResellerListNewsCentres_Item[]
> list_array = new
> ReturnWeb_AdminResellerListNewsCentres_Item[0];
> list_array =
> (ReturnWeb_AdminResellerListNewsCentres_Item[])
> list.toArray(list_array);
> // 'list' in wsdl example
> result.setList(list_array);
>
> ret =
> Messages_Codes.SUCCESS.intValue();
>
>
> result.setSuccessErrorCode(ret);
>
> result.setErrorMessage(Messages_Codes.getcode(ret));
> return result;
>
> HTH,
> iksrazal
> http://www.braziloutsource.com/
>
> "None are more hopelessly enslaved than those who falsely believe they are free. -- Goethe"
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>
-- 
Mariano García González :: Analista Programador
-----------------------------------------------
Entel IT Consulting, SA
Tlf.    91 567 07 36
Mobile. 619 08 70 90