PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → How to send an array of objects to a Webservice ?
How to send an array of objects to a Webservice ?
Débuté par Ntt68, 01 sep. 2015 09:15 - 2 réponses
Membre enregistré
104 messages
Popularité : +1 (1 vote)
Posté le 01 septembre 2015 - 09:15
My Webservice is expecting an array of strings but I'm unable to pass the array to my Webservcice using WM20.
Here's the declaration of the array:
<s:element name="StopOpname">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="Authentication" nillable="true" type="tns:Authentication"/>
<s:element minOccurs="1" maxOccurs="1" name="Opname" nillable="true" type="tns:OpnameMainData"/>
<s:element minOccurs="0" maxOccurs="1" name="Wagons" type="tns:ArrayOfString2"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfString2">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="Wagon" nillable="true" type="s:string"/>
</s:sequence>
</s:complexType>

So element "Wagons" should contain an array of 'wagon'





but I'm unable to assign an array of strings to the webservice:
arr_Wagons is Array of strings
results is a RFWS.StopOpnameResponse
params is a RFWS.StopOpname

params.Wagons = arr_Wagons
results = RFWS.StopOpname(params)

WM throws an exception at line 5 (params.Wagons = arr_Wagons). WM is saying the variable params.Wagons is not a subscripted element. How can I solve this kind of problem ? Please help
Posté le 01 septembre 2015 - 09:57
I wrote a webservice in java that sends a List<String> result = new ArrayList<String>() to my andorid app;

in WM I process it as follows:

v1 is wsKAMapp.getListOfMeldingTypes
v2 is wsKAMapp.getListOfMeldingTypesResponse
v2 = wsKAMapp.getListOfMeldingTypes(v1)

FOR ... ...
nID is int = v2.return[i]
sType is string = v2.return[i + 1]
END



don't know how it's the other way around
Posté le 07 septembre 2015 - 10:47
I've just found the solution, the array of 'Wagon' (instead of 'Wagons')

IF garr_Wagons..Occurrence > 0 THEN
params is a RFWS.StopOpname
results is a RFWS.StopOpnameResponse


FOR i=1 TO garr_Wagons..Occurrence
params.Wagons.Wagon[i] = garr_Wagons[i]
END

results = RFWS.StopOpname(params)
END