2

My web service is returning quite a bit of data, so i'm storing it in an arraylist and returning that to my application. I don't know whether or not this is the preferred method or not. When the arraylist is returned and displayed in my application, it also displays the arraylists "anyType" section. I'm new to this whole process so i'm sure i'm missing something somewhere or going about this incorrectly. Can anyone point me in the right direction please?

bschultz
  • 4,244
  • 1
  • 25
  • 33

2 Answers2

0

Are the instances of the object in the ArrayList all the same type? If so, then you might want to expose an IEnumerable<T> (where T is of that type) and then regenerate whatever proxies you are using on Android. This will probably give you a strongly-typed list which you can then consume more easily.

casperOne
  • 73,706
  • 19
  • 184
  • 253
  • Yes, it's returning all string values. Do you have a code snippet for that? If not i'm sure i can find and example on google. Also, do you know if there's anyway to separate each string value? – bschultz Jun 09 '10 at 18:11
  • @benjamin schultz: You just return IEnumerable, which List implements. As for separating each string value, what do you mean? – casperOne Jun 09 '10 at 20:37
  • Sorry if it's confusing! Basically, I have a VB .net ws which calls upon a stored procedure that retrieves string values from my database (string values such as all the states within a country). I loop through and get all the states and store them in an arraylist (i've also been testing substituting arraylist for just a list of strings). Then I return that arra list to my application, and from there i want to bind that to a ListView. ...continuing post on different comment... – bschultz Jun 16 '10 at 22:16
  • I can get so far as to returning my arraylist to my application but when it gets there it contains all the unnecessary anyType{ junk, and i don't recognize that as something i can parse. Would i be better off trying to find another way to do all of this? /long winded explanation Thanks again man for all your help! – bschultz Jun 16 '10 at 22:17
0

I have implemented such a thing before. I followed a different approach.

First, I suggest you insert a sort of delimiter like "#" to separate each individual item of your ArrayList. You can refer this for that.

That will help you return a Array of String in the form "item1#item2#item3#"

Now as far as the Android code using ksoap is concerned, have a look at this

In this code, check the soap calling method. I separate the String returned by my webservice using the "#" delimiter and store it in an array for populating a Spinner.

You can do as per what you want.

Hope I helped you.

Cheers

Community
  • 1
  • 1
Parth Doshi
  • 4,200
  • 15
  • 79
  • 129