BlackBerryForums.com : Your Number One BlackBerry Community      

»Sponsored Links



Reply
 
LinkBack Thread Tools
  (#1 (permalink)) Old
jeckerlin Offline
New Member
 
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Default BlackBerry JDE and kSoap and noobs - 07-18-2008, 03:27 PM

Hello,

I've noticed a lot of posts that deal with kSoap2 and JDE 4.x and people new to the platform. Being new to Java and Blackberry development, I struggled with it the past week and wanted to make a post so that others wont have to spend so much time hunting and searching like I did. I hope this helps.

I am assuming you have JDE 4.x installed.

see below for correct steps as of 2 pm 7/18/08.

Last edited by jeckerlin : 07-18-2008 at 04:03 PM. Reason: i failed
   
Reply With Quote
Sponsored Links
Please Login or Register to Remove these Advertisements!

  (#2 (permalink)) Old
jeckerlin Offline
New Member
 
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Default 07-18-2008, 04:02 PM

looks like I got a little ahead of myself. Looks like you need to do things a little differently so the blackberry device will load the ksoap files correctly.

Modified steps appear to be:
1) You need a preverified ksoap2-j2me-core-2.1.2.jar (attached) file. The ones from the kSoap site aren’t preverified and when attempting to do so it failed. I attempting to go through a preverification process but have been unsuccessful. I obtained the attached jar from a post by richard.puckett of a preverified ksoap2-j2me-core-2.1.2.jar file.

Since I'm new to the forums, I cant specify a direct link to the file. If you do a search for a thread called 'Preverified ksoap2' you can find Richard's link
to the file.

2) Within your JDE project, create a ‘lib’ folder. Using Windows Explorer, create a lib folder within your project and put the ksoap2-j2me-core-2.1.2.jar file in there.


3) Create a new 'Library' in your JDE workspace called kSoap. Add the preverified ksoap2-j2me-core-2.1.2.jar in the lib folder to that library.

4) Set the project dependencies to depend on the new library. Right click your main project -> select project dependencies -> select the kSoap library as a dependency

5) compile w/o errors

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();
}
}
}

Last edited by jeckerlin : 07-18-2008 at 06:21 PM. Reason: failed again
   
Reply With Quote
  (#3 (permalink)) Old
jeckerlin Offline
New Member
 
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Default 07-18-2008, 05:19 PM

Here is another example passing in a simple string parameter:

java:
String serviceUrl = <url to web service>;
String serviceNamespace = "h t tp ://tempuri.org/";
String soapAction = h t tp://tempuri.org/HelloWorldParam";
String methodName = "HelloWorldParam";

SoapObject rpc = new SoapObject(serviceNamespace, methodName);
rpc.addProperty("Name", "Jeff");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;

HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

String result = null;

try
{
ht.call(soapAction, envelope);
result = (envelope.getResult()).toString();
}
catch(org.xmlpull.v1.XmlPullParserException ex2){

}
catch(Exception ex){
String bah = ex.toString();
}


.net web service
namespace TestService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "h t tp : //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();
}

[WebMethod]
public string HelloWorldParam(string Name)
{
return "Hello " + Name;
}
}
}
   
Reply With Quote
  (#4 (permalink)) Old
jeckerlin Offline
New Member
 
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Default 07-18-2008, 06:29 PM

User a complex type from a .net web service:

java:
String serviceUrl = "h t t p://192.168.0.103/BBService/Service1.asmx";
String serviceNamespace = "h t t p//tempuri.org/";
String soapAction = "h t t p://tempuri.org/HelloWorldComplexType";
String methodName = "HelloWorldComplexType";

SoapObject rpc = new SoapObject(serviceNamespace, methodName);
rpc.addProperty("Name", "Jeff");
rpc.addProperty("Password", "nonya");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;

HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

String result = null;

try
{
ht.call(soapAction, envelope);
result = (envelope.getResult()).toString();
}
catch(org.xmlpull.v1.XmlPullParserException ex2){

}
catch(Exception ex){
String bah = ex.toString();
}

.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();
}

[WebMethod]
public string HelloWorldParam(string Name)
{
return "Hello " + Name;
}


[WebMethod]
public user HelloWorldComplexType(string Name, string Password)
{
user myUser = new user(Name, Password);

return myUser;
}

public class user
{
public user()
{


}

public user(string name, string pwd)
{
usrName = name;
usrPassword = pwd;
}

public string usrName { get; set; }

public string usrPassword { get; set; }
}
}
}
   
Reply With Quote
  (#5 (permalink)) Old
jeckerlin Offline
New Member
 
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Default 07-18-2008, 06:33 PM

nice tutorial

h t t p : / / w w w . ddj.com/mobile/208800166;
jsessionid=WMSG5RH5VNUR0QSNDLRSKH0CJUNN2JVN?pgno=2
   
Reply With Quote
  (#6 (permalink)) Old
sajika Offline
Knows Where the Search Button Is
 
Posts: 17
Join Date: May 2008
Model: 8310
PIN: N/A
Carrier: ATT
Default 07-22-2008, 02:52 PM

Thank you...very useful, I have been struggling to get this working
   
Reply With Quote
  (#7 (permalink)) Old
New Member
 
Posts: 10
Join Date: Aug 2008
Model: None!
PIN: N/A
Carrier: Vodafone
Default 08-28-2008, 01:16 AM

Excellant jeckerlin, appreciate you taking the time to help out us newbies.

The only thing i'm having problems with is that i am using Eclipse and can't seem to get the ksoap libraries to compile along with the rest of the code into 1 cod file. You describe how to do this in JDE, any ideas how to in Eclipse?

Thanks
   
Reply With Quote
  (#8 (permalink)) Old
laran Offline
New Member
 
Posts: 2
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: Verizon
Default I/O Error - 09-26-2008, 01:55 AM

I/O Error: Import file not found: ..\ksoap\ksoap.jar
Error while building project

That's the error I get when I follow the directions above. The project I created I made a Library project. There is no ksoap.jar. Don't know why there would be.

Any ideas on a fix?
   
Reply With Quote
  (#9 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 711
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 09-26-2008, 03:13 AM

Quote:
Originally Posted by laran View Post
I/O Error: Import file not found: ..\ksoap\ksoap.jar
Error while building project
1) You need a preverified ksoap2-j2me-core-2.1.2.jar (attached) file


java developer, Devinto, hamburg/germany
   
Reply With Quote
  (#10 (permalink)) Old
laran Offline
New Member
 
Posts: 2
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: Verizon
Default 09-26-2008, 08:43 AM

Quote:
Originally Posted by simon.hain View Post
1) You need a preverified ksoap2-j2me-core-2.1.2.jar (attached) file
I verified the jar myself. Is that not good enough?
   
Reply With Quote
  (#11 (permalink)) Old
sridhark Online
New Member
 
Posts: 2
Join Date: Sep 2008
Model: 8310
PIN: N/A
Carrier: at&t
Default 10-01-2008, 08:20 AM

Thanks a lot.. Nice tutorial.. My issue is solved..
   
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On






Copyright © 2004-2008 BlackBerryNews.com, BlackBerryFAQ.com, BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of Research In Motion Limited.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.1