Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling web services in blackberry

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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 "java.io.InterruptedIOException: 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.



Thanks




======================================================================================
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 = "http://tempuri.org/")]
[WebService(Namespace = "http://localhost:2901/")]
//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//[System.ComponentModel.ToolboxItem(false)]
public class Service : System.Web.Services.WebService
{

[WebMethod]

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

[WebMethod]
public String fnAddNumbers(int a, int b)
{
return "From Server, Hello - " + (a + b);
}

[WebMethod]
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();
theApp.enterEventDispatcher();
}

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

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

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);

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 {
ht.call(soapAction, 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() {
super();
LabelField title = new LabelField("HelloWorld Web Service Sample",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
textField = new RichTextField("Hello World! from Web Service");
add(textField);
}

public void setScreenTest(String text) {
textField.setText(text);
}

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

======================================================================================

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Naayl,

Is islam has answered your question??


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

Cheers
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic