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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
WesleyT
Posts: 206
Registered: ‎07-02-2010
My Carrier: Vodacom

Image takes long sending to webservice, Help.

Hello

 

I am sending an image to a webservice, The Image sends and everything is working fine. The only problem i am having now is that it takes long. What factors are involved here that could be "tweaked" to reduce the time it takes to send it to the webservice. Except the size of the image, Which i have catered for.

 

Thanks in advance.

Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

Re: Image takes long sending to webservice, Help.

I'm not sure there is much you can do, the time taken is likely to be a function of the connection speed.

 

How are you sending it?

Please use plain text.
Developer
simon_hain
Posts: 13,817
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Image takes long sending to webservice, Help.

base64 encoded images are about 1/3 bigger, that's what you sacrificing i guess

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
WesleyT
Posts: 206
Registered: ‎07-02-2010
My Carrier: Vodacom

Re: Image takes long sending to webservice, Help.

[ Edited ]

Thank you for your replies,

 

This is the code snipit of how i send the image

 

 

Location location = lp.getLocation(timeout);
							                 longitude = location.getQualifiedCoordinates().getLongitude();
							                 latitude = location.getQualifiedCoordinates().getLatitude();
							                 SoapObject request = new SoapObject("http://tempuri.org/", "SaveLocation");      
							                request.addProperty("image",Base64.encode(_raw));							                                
									request.addProperty("Long", longitude + "");
									request.addProperty("Lat", latitude + ""); 
									request.addProperty("notes", descrip.getText());
									SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
									envelope.bodyOut = request;	
									envelope.dotNet = true;
									envelope.encodingStyle = SoapSerializationEnvelope.XSD;
									ht = new HttpTransport("url");

Sorry for the above format it does not seem to want work with me :smileyhappy:

 

Any advise on how to improve this will be greatly appreciated.

 

Regards

 

 

Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

Re: Image takes long sending to webservice, Help.

[ Edited ]

I presume the image is a jpg?  If not what format is it? 

 

As Simon says, you are making it larger using Base64 which is not helping.  But not sure what else you can do here.

Please use plain text.
Developer
WesleyT
Posts: 206
Registered: ‎07-02-2010
My Carrier: Vodacom

Re: Image takes long sending to webservice, Help.

[ Edited ]

Simon,

 

The image extension is in .bmp format, The image's source comes from the BB Devices camera. What should i use other than Base64 if there is a better way ? If you have do this before could you inform as to what the acceptable time it should take to send an image to a webservice ?

 

Again i cannot thank you all enough for your help and advice

 

Regards

Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

Re: Image takes long sending to webservice, Help.

You have to encode binary data in some way to transport in an XML format - Base64 is as good as any I am aware of.  Maybe Simon has another option.

 

Re the format, the camera normally delivers in jpg format doesn't it.  If not than converting to a jpg would make the image significantly smaller, though it is a lossy compression.  Perhaps png?  I must admit that I have never done either.  When I have sent pictures back from the camera, they were jpgs. 

 

Re time, as noted above, it dopes depend on the connection type.  For a slow GPRS service I work on 1K per second.  Have you considered only dong this over WiFi?

Please use plain text.
Developer
simon_hain
Posts: 13,817
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Image takes long sending to webservice, Help.

no other(better) options from my side. i usually try to upload binary data in binary format, but if you are required to use a webservice for it, not your fault.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
WesleyT
Posts: 206
Registered: ‎07-02-2010
My Carrier: Vodacom

Re: Image takes long sending to webservice, Help.

Thank you Simon and Peter,

 

So basically what i have done with the code above, is pretty much acceptable ? The speed is just one of those things a person must deal with ?

Please use plain text.