BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-18-2008, 03:27 PM   #1
jeckerlin
New Member
 
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
Default 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  
Old 07-18-2008, 04:02 PM   #2
jeckerlin
New Member
 
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
Default

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  
Old 07-18-2008, 05:19 PM   #3
jeckerlin
New Member
 
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
Default

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  
Old 07-18-2008, 06:29 PM   #4
jeckerlin
New Member
 
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
Default

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  
Old 07-18-2008, 06:33 PM   #5
jeckerlin
New Member
 
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Posts: 6
Default

nice tutorial

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

Thank you...very useful, I have been struggling to get this working
Offline  
Old 08-28-2008, 01:16 AM   #7
FerminRomeroDeTorres
Knows Where the Search Button Is
 
Join Date: Aug 2008
Location: Scotland
Model: None!
PIN: N/A
Carrier: Vodafone
Posts: 31
Default

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  
Old 09-26-2008, 01:55 AM   #8
laran
New Member
 
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: Verizon
Posts: 2
Default 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  
Old 09-26-2008, 03:13 AM   #9
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

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
Offline  
Old 09-26-2008, 08:43 AM   #10
laran
New Member
 
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: Verizon
Posts: 2
Default

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?
Offline  
Old 10-01-2008, 08:20 AM   #11
sridhark
New Member
 
Join Date: Sep 2008
Model: 8310
PIN: N/A
Carrier: at&t
Posts: 2
Default

Thanks a lot.. Nice tutorial.. My issue is solved..
Offline  
Old 10-14-2008, 09:02 PM   #12
skraj72
New Member
 
Join Date: Oct 2008
Model: 8130
PIN: N/A
Carrier: Bell Mobility
Posts: 3
Default 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  
Old 10-15-2008, 02:26 AM   #13
goulamass
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Default

Hum did you add the librairie to the project and be successfull when importing librairies??
Offline  
Old 10-21-2008, 07:28 PM   #14
skraj72
New Member
 
Join Date: Oct 2008
Model: 8130
PIN: N/A
Carrier: Bell Mobility
Posts: 3
Default 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  
Old 10-21-2008, 07:39 PM   #15
PymbleSoftware
Knows Where the Search Button Is
 
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: internal
Posts: 15
Default

Quote:
Originally Posted by skraj72 View Post
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.
__________________
www.pymblesoftware.com
P.O. Box 121,
Pymble,
NSW 2073
AUSTRALIA. +61 2 99830308
Offline  
Old 10-22-2008, 09:33 AM   #16
sickned
Knows Where the Search Button Is
 
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: Unknow
Posts: 42
Default

http://www.blackberryforums.com/deve...-tutorial.html
Offline  
Old 12-09-2008, 03:10 AM   #17
jacytan
Thumbs Must Hurt
 
Join Date: Oct 2008
Model: 8800
PIN: N/A
Carrier: Globe
Posts: 52
Default

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  
Old 12-30-2008, 02:36 AM   #18
Meenal
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Default

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  
Old 01-05-2009, 09:24 AM   #19
tbi
New Member
 
Join Date: Dec 2008
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 4
Default

@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  
Old 01-08-2009, 02:47 PM   #20
tbi
New Member
 
Join Date: Dec 2008
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 4
Default

Quote:
Originally Posted by tbi View Post
@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  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


ResQGARD Military Kit Impedance Threshold Device 12-0706-000 NSN 6515015758173 picture

ResQGARD Military Kit Impedance Threshold Device 12-0706-000 NSN 6515015758173

$25.00



LCR45 Atlas Passive Component Impedance Analyser (Model LCR45) PEAK ELECTRONICS picture

LCR45 Atlas Passive Component Impedance Analyser (Model LCR45) PEAK ELECTRONICS

$133.00



BECO Universal Impedance Bridge Model 315A, Brown Electro Measurement Corp. 315A picture

BECO Universal Impedance Bridge Model 315A, Brown Electro Measurement Corp. 315A

$139.00



TC ESI Impedance Bridge Model 250-DA Serial 1394 Electro-MeasurementS Oregon USA picture

TC ESI Impedance Bridge Model 250-DA Serial 1394 Electro-MeasurementS Oregon USA

$69.99



Digital Ohmmeter LCD Audio Impedance Test Meter Speaker Voice Resistor System picture

Digital Ohmmeter LCD Audio Impedance Test Meter Speaker Voice Resistor System

$56.99



BECO Universal Impedance Bridge Model 315A, Brown Electro Measurement Corp. 315A picture

BECO Universal Impedance Bridge Model 315A, Brown Electro Measurement Corp. 315A

$129.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.