File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes calling web services in blackberry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Reply locked New topic

calling web services in blackberry

Naayl kazmi

Joined: Mar 22, 2011
Posts: 1
Hi, I am using Blackberry plugin for Java-Eclipse to write blackberry code on Windows XP SP3

I am using ksoap2.jar in my application for webservice call.

My webservice having one method called "HelloServer".

This code will return " Local connection timed out after ~ 120000" exception.

Following is the code

1.How can i solve this problem..

2. What are the ways i have to implement in my code.


My .NET Web Service Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

namespace HelloWorldService
//[WebService(Namespace = "")]
[WebService(Namespace = "http://localhost:2901/")]
//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService


public String HelloServer(String msg)
return "From Server, Hello - " + msg;

public String fnAddNumbers(int a, int b)
return "From Server, Hello - " + (a + b);

public String ShowMessage()
return "Welcome to KSoap2 Library";

My BlackBerry Code

package com.criagagreen.sample;

import java.util.Date;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;

//import net.rim.device.api.system.*;

public class HelloWorld extends UiApplication {
public static void main(String[] args) {
HelloWorld theApp = new HelloWorld();

public HelloWorld() {
pushScreen(new HelloWorldScreen());
//String serviceUrl = "http:// <SERVER>/HelloWorldService/Service.asmx";
String serviceUrl = "http://localhost:2901/Service.asmx";
String serviceNamespace = "";
String soapAction = "http://localhost:2901/HelloServer";

SoapObject rpc = new SoapObject(serviceNamespace, "HelloServer");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(

envelope.bodyOut = rpc;

envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
rpc.addProperty("msg", (new Date()).toString());

HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
String result;

try {, envelope);
result = (envelope.getResponse()).toString();
} catch (Exception ex) {
result = ex.toString();
((HelloWorldScreen) this.getActiveScreen()).setScreenTest(result);

final class HelloWorldScreen extends MainScreen

private RichTextField textField;

public HelloWorldScreen() {
LabelField title = new LabelField("HelloWorld Web Service Sample",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
textField = new RichTextField("Hello World! from Web Service");

public void setScreenTest(String text) {

public boolean onClose() {
Dialog.alert("Goodbye! from Web Service");
return true;


islam farid

Joined: Jul 18, 2011
Posts: 1
you should launck MDS in order to connect your web service you have two choices
1-download it from the internet
2-mark the checkbox in the run configurations then simulators
nishan satharasinghe

Joined: Aug 27, 2008
Posts: 14
Hi Naayl,

Is islam has answered your question??

Please post if it is , otherwise we can have a look on to it.

I agree. Here's the link:
subject: calling web services in blackberry
It's not a secret anymore!