Firstly this is my first post as a tutorial. So please don't care about short comings. I myself went through a lot of tutorials to develop a simple application on a blackberry device but sadly dint get much information. So this is for all those people who tried and dint get far and neither got much help..
I am using Eclipse ver 3.4.0( Apparently 3.4.1 is also supported but dint work for me), BlackBerry_JDE_PluginFull_1.0.0.67 , and ksoap2 which i am attaching here and simulators of ur choice (again only device software ver 4.3 and above)
If u r downloading the Ksoap2 library from elsewhere please make sure that it is preverified.
Step 1:
Create a new Blackberry Project.
After Creating a new project->Right click on the project->Project Properties-> Blackberry Project Properties-> Application->Project type->Library
Step 2:
Create a folder called "lib" at this new library project.
Step3:
Copy the ksoap2 preverified at this post to the lib folder. Right click on the file and select "Add to build path"
Step 4:Now Just build it once. Now your ready to use this is your application.
For your application.
Step5:In the Object explorer create a new project .
Step 6: Right click on the project -> Properties -> Java Build Path -> Libraries -> Add Jars... select Ksoap2.jar
Step 7: If you have noticed in previous posts many people have mentioned to add the created library to the project dependencies.. But there is no such option in Eclipse. It is only there if you use Blackberry JDE and yu are better off not using it in case you dont have any experience in Java cos it simply isnt worth it.
what you need to do here is right click on the project and there will be an option to add Project references. Click on it and it will contain the previous library project that you created. (P.S. You wont find it if its not in the same workspace). Check it and give add.
Thats it . Your done. You can go ahead and use the library. It will work like a charm..
Post back for Queries. All suggestions and criticisms welcome..Happy Coding!!!
P.S.
The preverified file and sample code that i have attached was taken from a previous post by Sickned.. I thank him for helping me get started.
And this is some sample code to access a .Net web service that i got from another post by Jackerlinn..
I thank hims for his post as well..
Code:
Below is simple code to call a .Net web service:
code extract from java file:
String serviceUrl = "<url to web service>l";
String serviceNamespace = "h t t p : / / tempuri . org /";
String soapAction = "h t t p : / / tempuri.org / HelloWorld";
SoapObject rpc = new SoapObject(serviceNamespace, "HelloWorld");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
try
{
ht.call(soapAction, envelope);
String result = (envelope.getResult()).toString();
}
catch(org.xmlpull.v1.XmlPullParserException ex2){
}
catch(Exception ex){
String bah = ex.toString();
}
Code Extract from .Net web Service
namespace TestService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "h t t p : / / tempuri . org /")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World" + System.DateTime.Now.ToString();
}
}
}