04-27-2010 08:44 AM
Hey all, I was wondering if someone can help me with an issue. I'm using a .net web service that is pushing over a collection of person objects when a person runs a query from the blackberry phone. To implement this I'm using ksoap2. In my service I'm sending in a string as the parameter. I'm returning the collection of persons that contain the firstname, lastname, address, race, sex. I'm also trying to send over an image. Now, I've gotten it to work just fine when not including the parameters for the image. In my class on the .net side in my person class I have the public property "image" which is a string. I get the bytes of the image and convert it to a base 64 string:
MemoryStream ms = new MemoryStream();
System.Drawing.Bitmap.bmp = new System.Drawing.Bitmap(imagePath);
p.image = Convert.ToBase64String(ms, GetBuffer());
Note: in my output I can see the 64Encoding string.
On the blackberry side I have:
byte imageArray = ((person)personVector.elementAt(i)).image.getBytes
EncodedImage bitmap =
EncodedImage.createEncodedImage(imageArray, 0, imageArray.length);
gridMgr.add( new BitmapField(bitmap.getBitmap());
Unfortunately, my vector count shows up as being empty and I keep get getting a parsing error. As I mentioned before if I remove the Image Property on both sides it works like a charm. I've tried using just about everything. Any ideas as to how to get the image over using ksoap? I tried making the image property in both classes as byte arrays but had no success. My problem when using the byte array was in the person class on the blackberry side for the PropertyInfo I didn't know what to use (e.g. STRING_CLASS, OBJECT_CLASS, LONG_CLASS); anyhow neither worked. What do you suggest?
Solved! Go to Solution.
05-05-2010 11:14 AM
I've been able to successfully get the bytes of the image over to the device by doing the following in my seriealize class.
In the getProperty method I'm using the following:
info.type = MarshalBase64.BYTE_ARRAY_CLASS;
05-05-2010 12:18 PM
Is this related to the same post as http://supportforums.blackberry.com/t5/Java-Develo
07-07-2010 05:47 PM
Could you show me please the code you implemented to comunicate with the web service In order to obtain the collection of persons that contain the firstname, lastname, address, race, sex? i am making an application in BlackBerry to obtein complex objects from a web service..Thanks