|
|
|
07-18-2008, 03:27 PM
|
#1
|
New Member
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
|
BlackBerry JDE and kSoap and noobs
Please Login to Remove!
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
|
Offline
|
|
07-18-2008, 04:02 PM
|
#2
|
New Member
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
|
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 arenxxx8217;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 xxx8216;libxxx8217; 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
|
Offline
|
|
07-18-2008, 05:19 PM
|
#3
|
New Member
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
|
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;
}
}
}
|
Offline
|
|
07-18-2008, 06:29 PM
|
#4
|
New Member
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
|
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; }
}
}
}
|
Offline
|
|
07-18-2008, 06:33 PM
|
#5
|
New Member
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
|
nice tutorial
h t t p : / / w w w . ddj.com/mobile/208800166;
jsessionid=WMSG5RH5VNUR0QSNDLRSKH0CJUNN2JVN?pgno=2
|
Offline
|
|
07-22-2008, 02:52 PM
|
#6
|
Knows Where the Search Button Is
Join Date: May 2008
Model: 8310
PIN: N/A
Carrier: ATT
Posts: 17
|
Thank you...very useful, I have been struggling to get this working
|
Offline
|
|
08-28-2008, 01:16 AM
|
#7
|
Knows Where the Search Button Is
Join Date: Aug 2008
Location: Scotland
Model: None!
PIN: N/A
Carrier: Vodafone
Posts: 31
|
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
|
Offline
|
|
09-26-2008, 01:55 AM
|
#8
|
New Member
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: Verizon
Posts: 2
|
I/O Error
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?
|
Offline
|
|
09-26-2008, 03:13 AM
|
#9
|
CrackBerry Addict
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
|
Quote:
Originally Posted by laran
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
|
Offline
|
|
09-26-2008, 08:43 AM
|
#10
|
New Member
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: Verizon
Posts: 2
|
Quote:
Originally Posted by simon.hain
1) You need a preverified ksoap2-j2me-core-2.1.2.jar (attached) file
|
I verified the jar myself. Is that not good enough?
|
Offline
|
|
10-01-2008, 08:20 AM
|
#11
|
New Member
Join Date: Sep 2008
Model: 8310
PIN: N/A
Carrier: at&t
Posts: 2
|
Thanks a lot.. Nice tutorial.. My issue is solved..
|
Offline
|
|
10-14-2008, 09:02 PM
|
#12
|
New Member
Join Date: Oct 2008
Model: 8130
PIN: N/A
Carrier: Bell Mobility
Posts: 3
|
cannot find symbol for SoapObject
Hi,
I followed the above steps and I am getting an error "cannot find symbol" SoapObject. I followed the first steps as described above and it compiled OK. As soon as I added the SoapObject code I get this error. Any suggestions how to fix this? I am trying to call a .NET Web service developed using VS2005.
Thanks,
Sundar
|
Offline
|
|
10-15-2008, 02:26 AM
|
#13
|
Talking BlackBerry Encyclopedia
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
|
Hum did you add the librairie to the project and be successfull when importing librairies??
|
Offline
|
|
10-21-2008, 07:28 PM
|
#14
|
New Member
Join Date: Oct 2008
Model: 8130
PIN: N/A
Carrier: Bell Mobility
Posts: 3
|
calling .NET Web Service
Yes I added the libraries to the project. What is the import statement to call the SoapObject classes?
Last edited by skraj72; 10-21-2008 at 07:34 PM..
|
Offline
|
|
10-21-2008, 07:39 PM
|
#15
|
Knows Where the Search Button Is
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: internal
Posts: 15
|
Quote:
Originally Posted by skraj72
Yes I added the libraries to the project. What is the import statement to call the SoapObject classes?
|
Huh?
// SOAP Library imports.
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
RR.
|
Offline
|
|
10-22-2008, 09:33 AM
|
#16
|
Knows Where the Search Button Is
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: Unknow
Posts: 42
|
|
Offline
|
|
12-09-2008, 03:10 AM
|
#17
|
Thumbs Must Hurt
Join Date: Oct 2008
Model: 8800
PIN: N/A
Carrier: Globe
Posts: 52
|
hi jeckerlin,
your samples are very helpful. thanks so much for that.
now, im trying something new. i want to pass a complex type as a parameter to the webmethod. but everytime i do so, the contents of the complex type get replaced with the values that are defined in the default constructor. if the default constructor is empty, the values become null. is there a solution to this problem? i've looked everywhere and nothing has been successful.
please please help!
thanks,
jaclyn
|
Offline
|
|
12-30-2008, 02:36 AM
|
#18
|
Thumbs Must Hurt
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
|
Hi all,
I have gone through the posts above, and its been real helpful. It works fine on the simulator. But i am having a problem while installing on the device. When i install the application on the device, and try to open it, it gives an error: "Error starting testKsoap: Module 'kSoap' not found." Following is the alx i am using:
************************************
<loader version="1.0">
<application id="testKsoap">
<name >
</name>
<description >
</description>
<version >
</version>
<vendor >
MyCompany
</vendor>
<copyright >
Copyright (c) 2008 MyCompany
</copyright>
<fileset Java="1.24">
<directory >
</directory>
<files >
testKsoap.cod
</files>
</fileset>
<application id="kSoap">
<name >
</name>
<description >
</description>
<version >
</version>
<vendor >
MyCompany
</vendor>
<copyright >
Copyright (c) 2008 MyCompany
</copyright>
<fileset Java="1.24">
<directory >
</directory>
<files >
kSoap.cod
</files>
</fileset>
</application>
</application>
</loader>
************************************
Basically, the kSoap library module is not getting installed on the device. I dont know what i am doing wrong. Please help.
__________________
Thanks
Meenal
|
Offline
|
|
01-05-2009, 09:24 AM
|
#19
|
New Member
Join Date: Dec 2008
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 4
|
@Meenal: I got the same error - what I ended up doing is installing the ksoap library separately on the blackberry device - this allows you app to execute with errors.
I'm having a different problem with ksoap/bb:
I've got my app running without issues on the simulator but when I run it on the actual device, it says its sending data to my .net web-service but I don't receive anything on the other end - anyone had this issue?
|
Offline
|
|
01-08-2009, 02:47 PM
|
#20
|
New Member
Join Date: Dec 2008
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 4
|
Quote:
Originally Posted by tbi
@Meenal: I got the same error - what I ended up doing is installing the ksoap library separately on the blackberry device - this allows you app to execute with errors.
I'm having a different problem with ksoap/bb:
I've got my app running without issues on the simulator but when I run it on the actual device, it says its sending data to my .net web-service but I don't receive anything on the other end - anyone had this issue?
|
Solution:
Figured out the BES server was causing this issue. My guess is, since this is an unsigned app, it wouldn't allow it to communicate with the web-service.
Tested out my app on phones that were not on BES and it worked every time.
|
Offline
|
|
|
|