Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

New Developer
Posts: 54
Registered: ‎10-07-2008
My Device: Not Specified

How to read arrays with ksoap2



My app now connects to the WS and works very fine with simple responses as strings, bool, etc. Thanks for your help provided from the forum´s users.


But now I have this bump. I cannot read a response of array.


This is my soap response



<?xml version="1.0" encoding="utf-8" ?> - <ArrayOfAnyType xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/"> <anyType xsi:type="xsd:string">value 1</anyType> </ArrayOfAnyType>


 This is my web service


/// <summary> /// GetTravels /// </summary> /// <param name="userId">userId</param> /// <returns>ArrayList</returns> [WebMethod] public ArrayList GetTravels(string userId) { ArrayList travels = new ArrayList(); int iuserId = int.Parse(userId); travels.Add("value 1"); return travels; }



And this is my Midlet Code



public MarshalHashtable GetTravelList(String userId){ MarshalHashtable response = new MarshalHashtable(); //SoapObject soapResponse; String soapAction = KSOAP.serviceNamespace + KSOAP.getTravels; SoapObject rpc = new SoapObject(KSOAP.serviceNamespace, KSOAP.getTravels); SoapSerializationEnvelope envelope = KSOAP.getSoapSerializationEnvelope(rpc); HttpTransport ht = KSOAP.getHttpTransport(); rpc.addProperty("userId", userId); ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); envelope.encodingStyle = SoapSerializationEnvelope.ENC; try { ht.call(soapAction, envelope); //response = (envelope).getResponse().toString(); //soapResponse = (SoapObject)envelope.getResponse(); response = (MarshalHashtable)envelope.getResponse(); } catch(org.xmlpull.v1.XmlPullParserException ex2){ String ex = ex2.toString(); } catch(Exception ex){ String exc = ex.toString(); } return response; }


I have tryed with HashTable, Vegctor and MarshalHashTable.


but i get a Casting error.


Can you help me please.


Thanks in advance ! Smiley Happy