Welcome!

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

Reply
Developer
Posts: 18
Registered: ‎01-27-2010
My Device: Curve 8330
My Carrier: Verizon
Accepted Solution

Getting Image Over Using Web Service and Ksoap2

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);

bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);

 

p.image = Convert.ToBase64String(ms, GetBuffer());

bmp.Dispose();

ms.Close();

 

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?

Developer
Posts: 18
Registered: ‎01-27-2010
My Device: Curve 8330
My Carrier: Verizon

Re: Getting Image Over Using Web Service and Ksoap2

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;

 

Developer
Posts: 91
Registered: ‎11-24-2009
My Device: Storm

Re: Getting Image Over Using Web Service and Ksoap2

Hello,

 

Is this related to the same post as http://supportforums.blackberry.com/t5/Java-Development/Decoding-a-byte-back-into-an-image/td-p/4971... posted by you?

-Luis Fernando

Remember to give Kudos(click on the star at your left) if this helped you.
Click on "Accept Solution" if the problem is resolved.
Espanol? Escribeme un mensaje privado.
Highlighted
Developer
Posts: 18
Registered: ‎01-27-2010
My Device: Curve 8330
My Carrier: Verizon

Re: Getting Image Over Using Web Service and Ksoap2

It is related; however, the new post is a new issue that I face.

Visitor
Posts: 1
Registered: ‎07-07-2010
My Device: 8310
My Carrier: Digitel

Re: Getting Image Over Using Web Service and Ksoap2

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