Connecting to webservice from BlackBerry

Tag: blackberry Author: liuyucai12345678 Date: 2010-10-19

I am connecting to a web server from a BlackBerry simulator for the 9630, to get an image and display it on screen.

But while testing this same app in the 8520 and 9700 simulators, it doesn't work. I think it didn't connect to the web service.

I need to be able to connect to a web service from all simulators.

String filepath="file:///store/home/user/loan1.jpg";
FileConnection fc = (FileConnection),Connector.READ_WRITE);
String photoXml=
byte[] imgArry=
    Base64InputStream.decode(new DataParsingComm().ILGetImage(photoXml));
EncodedImage image = EncodedImage.createEncodedImage(imgArry,0,imgArry.length);

BitmapField bitf=new BitmapField() {
    public void layout(int width, int height) {
        super.layout(100, 100);
HorizontalFieldManager bfm = new HorizontalFieldManager(FIELD_HCENTER); 

You don't need to start every question with "I am new to blackberry"
really i am new to blackberry.So i am using new to blackberry for every question

Best Answer

I think it didn't connect to the web service.

It seems you should verify this before asking your question. Set a breakpoint in the debugger, and see where code execution fails.

Other Answer1

Have you opened the mds simulator? The simulator needs it to access internet.


That is not correct. The simulator can do TCP without the MDS simulator if you append ;deviceside=true to the URL or configure a WLAN network. Your application just needs to figure out which type of connection works. That is usually a good idea anyway, because often some connection methods work while others do not work, even if they are available.

Other Answer2

Make sure you have MDS turned on. Use JSR172 webservices (see NetBeans documentation), and I don't think you can transfer and image direclty, you'll need to transfer a byte array.