| »Sponsored
Links |
BlackBerryApps.com Best Sellers
|
|
 |
|
New Member
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
|
BlackBerry JDE and kSoap and noobs -
07-18-2008, 04: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 05:03 PM.
Reason: i failed
|
|
|
|
|
New Member
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
|

07-18-2008, 05: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 07:21 PM.
Reason: failed again
|
|
|
|
|
New Member
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
|

07-18-2008, 06: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;
}
}
}
|
|
|
|
|
New Member
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
|

07-18-2008, 07: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; }
}
}
}
|
|
|
|
|
New Member
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
|

07-18-2008, 07:33 PM
nice tutorial
h t t p : / / w w w . ddj.com/mobile/208800166;
jsessionid=WMSG5RH5VNUR0QSNDLRSKH0CJUNN2JVN?pgno=2
|
|
|
|
|
Knows Where the Search Button Is
Posts: 17
Join Date: May 2008
Model: 8310
PIN: N/A
Carrier: ATT
|

07-22-2008, 03:52 PM
Thank you...very useful, I have been struggling to get this working
|
|
|
|
|
Knows Where the Search Button Is
Posts: 31
Join Date: Aug 2008
Location: Scotland
Model: None!
PIN: N/A
Carrier: Vodafone
|

08-28-2008, 02: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
|
|
|
|
|
New Member
Posts: 2
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: Verizon
|
I/O Error -
09-26-2008, 02: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?
|
|
|
|
|
CrackBerry Addict
Posts: 834
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
|

09-26-2008, 04:13 AM
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
|
|
|
|
|
New Member
Posts: 2
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: Verizon
|

09-26-2008, 09:43 AM
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?
|
|
|
|
|
New Member
Posts: 2
Join Date: Sep 2008
Model: 8310
PIN: N/A
Carrier: at&t
|

10-01-2008, 09:20 AM
Thanks a lot.. Nice tutorial.. My issue is solved..
|
|
|
|
|
New Member
Posts: 3
Join Date: Oct 2008
Model: 8130
PIN: N/A
Carrier: Bell Mobility
|
cannot find symbol for SoapObject -
10-14-2008, 10:02 PM
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
|
|
|
|
|
Talking BlackBerry Encyclopedia
Posts: 217
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
|

10-15-2008, 03:26 AM
Hum did you add the librairie to the project and be successfull when importing librairies??
|
|
|
|
|
New Member
Posts: 3
Join Date: Oct 2008
Model: 8130
PIN: N/A
Carrier: Bell Mobility
|
calling .NET Web Service -
10-21-2008, 08:28 PM
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 08:34 PM.
|
|
|
|
|
Knows Where the Search Button Is
Posts: 15
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: internal
|

10-21-2008, 08:39 PM
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.
|
|
|
|
|
Knows Where the Search Button Is
Posts: 42
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: Unknow
|

10-22-2008, 10:33 AM
|
|
|
|
|
Thumbs Must Hurt
Posts: 51
Join Date: Oct 2008
Model: 8800
PIN: N/A
Carrier: Globe
|

12-09-2008, 03:10 AM
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
|
|
|
|
|
Thumbs Must Hurt
Posts: 113
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
|

12-30-2008, 02:36 AM
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.
|
|
|
|
|
New Member
Posts: 4
Join Date: Dec 2008
Model: 9000
PIN: N/A
Carrier: Rogers
|

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

01-08-2009, 02:47 PM
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.
|
|
|
|
|
New Member
Posts: 5
Join Date: Mar 2009
Model: Bold
PIN: N/A
Carrier: Rogers
|
Problem using ksoap for accessing web services -
03-16-2009, 01:32 PM
Hi,
I m a newbie BB developer trying to use ksoap on BB JDE 4.3 to connect to a web service.
I followed the steps given in this thread.
Downloaded ksoap2-j2me-core-prev-2.1.2.
Placed the above file in C:\BlackBerry JDE 4.3.0\bin.
Preverified the file with command preverify -classpath "C:\BlackBerry JDE 4.3.0\lib\net_rim_api.jar" ksoap2-j2me-core-prev-2.1.2.jar
Added the preverified file ( present in C:\BlackBerry JDE 4.3.0\bin) to my project in BB JDE 4.3 .
Did a build on the code and got the following output
Building Ksoap2
C:\BlackBerry JDE 4.3.0\bin\rapc.exe -quiet import=..\lib\net_rim_api.jar library=HelloWorldFolder\Ksoap2 HelloWorldFolder\Ksoap2.rapc warnkey=0x52424200;0x52525400;0x52435200 "C:\BlackBerry JDE 4.3.0\subash\HelloWorldFolder\Ksoap2Demo.java" "C:\BlackBerry JDE 4.3.0\jar\ksoap2-j2me-core-prev-2.1.2.jar" "C:\BlackBerry JDE 4.3.0\subash\HelloWorldProjectFolder\helloworld_jd e.png"
Note: C:\BlackBerry JDE 4.3.0\subash\HelloWorldFolder\Ksoap2Demo.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\BlackBerry JDE 4.3.0\subash\HelloWorldFolder\Ksoap2Demo.java:117: Warning!: Invocation of questionable method: java.lang.String.<init>(String) found in: HelloWorldFolder.Ksoap2Demo$Ksoap2DemoScreen.obten erListaArticuloSOAP(String)
C:\BlackBerry JDE 4.3.0\subash\HelloWorldFolder\Ksoap2Demo.java:51: Warning!: inner class 'HelloWorldFolder.Ksoap2Demo$Ksoap2DemoScreen' should be declared static
C:\BlackBerry JDE 4.3.0\jar\ksoap2-j2me-core-prev-2.1.2.jar(org/ksoap2/serialization/MarshalHashtable$ItemSoapObject.class):1: Warning!: inner class 'org.ksoap2.serialization.MarshalHashtable$ItemSoa pObject' should be declared static
Build complete.
But when i run the program on the emulator, i m not seeing the app on the emulator. I ve given an icon , but it doesnt show up.
I dont know where the problem is . Do i have to have any other software up and running? Appreciateif you can help me.
Another thing to mention - i read somewhere that project dependencies have to be set. But when i right click the project and go to project dependencies, it shows ksoap2 , but it is disabled --> it does not allow me to select ksoap2.
Thanks
Last edited by subashbala : 03-16-2009 at 01:39 PM.
|
|
|
|
|
New Member
Posts: 2
Join Date: Mar 2009
Model: 9000
PIN: N/A
Carrier: O2 UK
|
Simple ksoap2 example -
04-01-2009, 04:57 AM
Hi
I am new to Java, Blackberry and ksoap2, so I was wrestling with this for a couple of days.
This article helped a lot:
h**p://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&arti cleId=102
If you need parameters, just use the addProperty method on the SoapObject to add them. And if you just have a string value as a return, you can always use (envelope.getResult()).toString() to get hold of it (instead of the vector stuff in the example).
Hope this helps. Sorry can't hotlink urls as I am a newbie
|
|
|
|
|
New Member
Posts: 3
Join Date: Apr 2009
Model: 7100T
PIN: N/A
Carrier: 02
|

04-02-2009, 07:05 AM
I'm new to blackberry and haven't worked in java in a long time.
Can some-one explain the benefits of using SOAP over the httpConnection method below (this is a snippet from a tutorial at: h t t p://w w w.ibm.com/developerworks/opensource/tutorials/os-blackberry/section4.html
params.append("identifier", id);
params.append("data", data);
String url = "h t t p://ibm.msi-wireless.com/posttransaction.php?"
+ params.toString();
System.out.println(url);
//Connecting to Server
httpConnection = (HttpConnection)Connector.open(url);
inputStream = httpConnection.openDataInputStream();
I posted a thread asking for the maximum size of a query string. I'm interested to know which of the 2 methods can handle large delimited lists the best.
|
|
|
|
|
New Member
Posts: 2
Join Date: Mar 2009
Model: 8800
PIN: N/A
Carrier: development
|
problem using ksoap2 for sending parameters -
04-02-2009, 04:33 PM
hi
I have been using ksoap2 for a couple of days and i can't send the parameters to my web service,I can connect it but i don't know what's the problem for sending parameters.
this is my code
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
public class webService {
public webService() {
String serviceUrl = "h t t p://192.168.44.250/SerW_SubirArch/SubirArch.asmx";
String serviceNamespace = "h t t p://192.168.44.250/SerW_SubirArch/";
String soapAction = "mx.com.medisist.WebService/SignosVitalesblack";
String methodName= "SignosVitalesblack";
SoapObject rpc = new SoapObject(serviceNamespace, methodName);
rpc.addProperty("idPaciente", String.valueOf(340).toString());
rpc.addProperty("glucosa",String.valueOf(120).toSt ring());
rpc.addProperty("Medicamento","Metformina tableta 1000mg");
rpc.addProperty("Cantidad",String.valueOf(5).toStr ing());
rpc.addProperty("medida","Pastillas");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
envelope.setOutputSoapObject(rpc);
HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
int result= -1;
try {
ht.call(soapAction, envelope);
result = Integer.valueOf((envelope.getResult()).toString()) .intValue();
} catch (org.xmlpull.v1.XmlPullParserException ex2) {
} catch (Exception ex) {
String bah = ex.toString();
System.out.println(bah);
}
}
}
I would appreciate much if you could help me
|
|
|
|
|
New Member
Posts: 2
Join Date: Mar 2009
Model: 8800
PIN: N/A
Carrier: development
|

04-03-2009, 11:30 AM
Quote:
Originally Posted by zona21
hi
I have been using ksoap2 for a couple of days and i can't send the parameters to my web service,I can connect it but i don't know what's the problem for sending parameters.
this is my code
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
public class webService {
public webService() {
String serviceUrl = "h t t p://192.168.44.250/SerW_SubirArch/SubirArch.asmx";
String serviceNamespace = "h t t p://192.168.44.250/SerW_SubirArch/";
String soapAction = "mx.com.medisist.WebService/SignosVitalesblack";
String methodName= "SignosVitalesblack";
SoapObject rpc = new SoapObject(serviceNamespace, methodName);
rpc.addProperty("idPaciente", String.valueOf(340).toString());
rpc.addProperty("glucosa",String.valueOf(120).toSt ring());
rpc.addProperty("Medicamento","Metformina tableta 1000mg");
rpc.addProperty("Cantidad",String.valueOf(5).toStr ing());
rpc.addProperty("medida","Pastillas");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
envelope.setOutputSoapObject(rpc);
HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
int result= -1;
try {
ht.call(soapAction, envelope);
result = Integer.valueOf((envelope.getResult()).toString()) .intValue();
} catch (org.xmlpull.v1.XmlPullParserException ex2) {
} catch (Exception ex) {
String bah = ex.toString();
System.out.println(bah);
}
}
}
I would appreciate much if you could help me
|
hi everybody
finally, I could transfer parameters to my web service, my mistake was that i was writing on the variable *serviceNamespace something like this: String serviceNamespace = "h t t p://192.168.44.250/SerW_SubirArch/";
the situation was happening because i had another nameSpace on my web Service it was:
[WebService(Namespace = "mx.com.medisist.WebService")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class SubirArch : System.Web.Services.WebService{
furthermore I had to put the same name on my code variable *serviceNamespace because it has to be the same String to pass the parameters, now my new code is:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Medisist;
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
public class webService {
public webService() {
String serviceUrl = "h t t p://192.168.44.250/SerW_SubirArch/SubirArch.asmx";
String serviceNamespace = "mx.com.medisist.WebService";
String soapAction = "mx.com.medisist.WebService/SignosVitalesblack";
String methodName="SignosVitalesblack";
SoapObject rpc = new SoapObject(serviceNamespace, methodName);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
rpc.addProperty("idPaciente","340");
rpc.addProperty("glucosa","120");
rpc.addProperty("Medicamento","Metformina tableta 1000mg");
rpc.addProperty("Cantidad","5");
rpc.addProperty("medida","Pastillas");
envelope.setOutputSoapObject(rpc);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSI;
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();
System.out.println(bah);
}
}
}
I appreciate much and i hope that this code can be helpfully
Last edited by zona21 : 04-03-2009 at 11:32 AM.
|
|
|
|
|
New Member
Posts: 4
Join Date: May 2009
Model: 9530
PIN: N/A
Carrier: Verizon
|

05-04-2009, 10:26 PM
Excellent post! What about sending a complex type? I can't seem to find much information on sending one, there's plenty available on recieving it back in the response, and I do have that part working.
Thanks.
|
|
|
|
|
New Member
Posts: 3
Join Date: Apr 2009
Model: 7100T
PIN: N/A
Carrier: None
|

06-22-2009, 09:41 PM
Thanks to jeckerlin for the initial post and everyone after for their contributions. I still struggled for longer than I would have like getting Eclipse, KSoap and the BB to play nice. I have since summarized my experience going from a clean machine to getting KSoap up and running on the device. I hope this helps someone else. It can be found here: w w w.craigagreen.com/index.php?/Blog/blackberry-and-net-webservice-tutorial-part-1.html
|
|
|
|
|
Thumbs Must Hurt
Posts: 62
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
|

06-23-2009, 01:38 PM
Well, that is a good idea!
But I bet it will be much more complicated
when it comes to deal with complex(  ) response from web server.
I looked over internet and could not find any good example
related to de-serialization of that response with ksoap2.
I am not sure if envelope.addMapping() works at all.
In my development I had to use SAX for that purpose,
which worked just fine 
|
|
|
|
|
New Member
Posts: 3
Join Date: Apr 2009
Model: 7100T
PIN: N/A
Carrier: None
|

07-03-2009, 01:55 PM
I can't seem to get both complex return types and input parameters working at the same time. They are mutually exclusive for me!
I was initially able to pass strings to my .NET service and return a string... no problem. But to return complex types I had to set the SoapRpcMethod attribute on the server. That now allows me to return a complex type, but now my input parameters aren't properly deserialized on the server. I've tried numerous things, even instantiating my own SoapPrimitive instance (as seen below).
I'm hoping that it's something as trivial as a bad namespace that I've overlooked. Any insight is much appreciated.
Java Client:
Code:
String serviceUrl = "h t t p : //xx.xxx.xxx.xxx/HelloWorldService/Service.
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;
envelope.addMapping("h t t p : //tempuri.org/encodedTypes", "Complex", new Complex().getClass());
HttpTransport ht = new HttpTransport(serviceUrl);
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
ht.debug = true;
try
{
// rpc.addProperty("a","45");
// rpc.addProperty("b","54");
rpc.addProperty("a",new SoapPrimitive(SoapSerializationEnvelope.XSD,"String","45"));
rpc.addProperty("b",new SoapPrimitive(SoapSerializationEnvelope.XSD,"String","54"));
ht.call(soapAction, envelope);
SoapObject body = (SoapObject)envelope.bodyIn;
String req = ht.requestDump;
String resp = ht.responseDump;
... and so on...
.NET Web Service:
Code:
[WebService(Namespace = "h t t p ://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.None)]
public class Service : System.Web.Services.WebService
{
[SoapRpcMethod]
[WebMethod]
public Complex[] HelloWorld(String a, String b)
{
...
}
}
|
|
|
|
|
Thumbs Must Hurt
Posts: 62
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
|

07-03-2009, 02:17 PM
Did not make sense to show this example, - it's everywhere and it works.
Again, try to use SAX parser to de-serialize complex response 
|
|
|
|
|
New Member
Posts: 3
Join Date: Apr 2009
Model: 7100T
PIN: N/A
Carrier: None
|

07-03-2009, 02:29 PM
Perhaps I wasn't clear in my previous post. I'm good with the deserializing the complex type back on the client.
My question now is "what am I doing incorrectly that is making my input parameters on the server be null"? As I mentioned earlier, I did have this working, but not when using SoapRpcMethod on the server.
By showing my sample code I'm hoping that there is something obvious that I've overlooked that someone could point out.
Thanks
|
|
|
|
|
Thumbs Must Hurt
Posts: 62
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
|

07-06-2009, 12:42 PM
Quote:
Originally Posted by cagreen
...my input parameters on the server be null...
|
I would check requestDump and responseDump first.
Input params types should be exactly the same in both dumps.
|
|
|
|
|
New Member
Posts: 1
Join Date: Jul 2009
Model: 8320
PIN: N/A
Carrier: Blackberry
|
JVM Error :104 -
07-28-2009, 02:42 AM
Hi,
I am using this tutorial and config project according to the mentioned steps. but when I run my project , an runtime error occurs:
"JVM Error : 104"
"Uncaught Runtime Exception"
How I run my project is :
Right click on project > Run As>Blackberry Simulator
Is this the right way ?
please give me more information about this type of applications.
Thanks.
|
|
|
|
|
Knows Where the Search Button Is
Posts: 17
Join Date: Aug 2009
Model: 8300
PIN: N/A
Carrier: Vodafone
|
Cant find Project dependencies!!! -
08-13-2009, 01:37 AM
Hi, I ve been tryin to do the same thing but with eclipse. In step 4 u mention that we need to go to project dependencies.. The same was mentioned in another post .
But am not able to find it.. Please help me out
|
|
|
|
|
New Member
Posts: 1
Join Date: Aug 2009
Model: n/a
PIN: N/A
Carrier: n/a
|
Send parameters OR be able to get back complex objects -
08-20-2009, 10:10 PM
Quote:
Originally Posted by cagreen
Perhaps I wasn't clear in my previous post. I'm good with the deserializing the complex type back on the client.
My question now is "what am I doing incorrectly that is making my input parameters on the server be null"? As I mentioned earlier, I did have this working, but not when using SoapRpcMethod on the server.
By showing my sample code I'm hoping that there is something obvious that I've overlooked that someone could point out.
Thanks
|
I am having the same problem. That is I can send parameters OR get back complex objects, but, not both. The two cases are:
- send parameters successfully and get back an untyped string that looks like this: "anyType{Id=-70; someList=anyType{" where anyType is not useful to me.
- Or, my parameters are sent as nulls, and I get something useful back. Something like this: "ObjectName1{Id=-3; someList=[ObjecName2{Id=-6;" where ObjectName1 & ObjectName2 are interesting to me.
The behavior is changed by including the [SoapRpcMethod] attribute above the method in my web service. With the attribute, I get the object back in a useful format, but, can not send parameters. Without it, the opposite.
Anyone have a solution to this?
Thanks,
Scott
|
|
|
|
|
New Member
Posts: 11
Join Date: Nov 2009
Model: 7100
PIN: N/A
Carrier: IT Programmer
|

11-19-2009, 01:45 AM
hai guys
nice tutorial...
i have exception, i dunno what should i do
this is exception : expected: START_TAG {h t t p:/ / schemas.xmlsoap. org/soap/envelope/}Envelope (position:START_TAG (empty) < br>@1:6 in java.io.InputStreamR eader@d590dbc)
|
|
|
|
|
New Member
Posts: 11
Join Date: Nov 2009
Model: 7100
PIN: N/A
Carrier: IT Programmer
|

11-19-2009, 02:05 AM
Quote:
Originally Posted by akangbro
hai guys
nice tutorial...
i have exception, i dunno what should i do
this is exception :
Code:
expected: START_TAG {h t t p:/ / schemas .xmlsoap. org/soap/envelope/}Envelope (position:START_TAG (empty) < br>@1:6 in java.io .InputStreamR eader@d590dbc)
|
this is my wsdl
Code:
< definitions targetName space="h tt p:/ / www.wso2 .org / php">
−
<types>
−
< xsd:schema elementFormDefault="qualified" targetNamespace="h tt p:/ / wso2. org/projects/wsf/php/ds">
< xsd:element name="gettrxjual" type="ns0:gettrxjual"/>
< xsd:element name="poliss" type="ns0:polissType"/>
−
< xsd:complexType name="gettrxjual">
−
< xsd:sequence>
< xsd:element name="noagen1" type="xsd:any"/>
< xsd:element name="noagen2" type="xsd:any"/>
< xsd:element name="noagen3" type="xsd:any"/>
< xsd:element name="noagen4" type="xsd:any"/>
< /xsd:sequence>
< /xsd:complexType>
−
< xsd:complexType name="polissType">
−
< xsd:sequence>
< xsd:element name="polis" minOccurs="0" maxOccurs="unbounded" nillable="true" type="ns0:polisType"/>
</ xsd:sequence>
</ xsd:complexType>
−
< xsd:complexType name="polisType">
−
< xsd:sequence>
< xsd:element name="nmleng" type="xsd:any"/>
< xsd:element name="tgllhr" type="xsd:dateTime"/>
< xsd:element name="ultah" type="xsd:any"/>
< xsd:element name="nmagen" type="xsd:any"/>
< xsd:element name="nopoli" type="xsd:any"/>
< xsd:element name="ketsta" type="xsd:any"/>
< xsd:element name="nomohp" type="xsd:any"/>
< /xsd:sequence>
< /xsd:complexType>
< /xsd:schema>
< / types>
−
< me ssage name="gettrxjual">
< par t name="parameters" element="ns0:gettrxjual"/>
< /me ssage>
−
< mes sage name="gettrxjualResponse">
< part name="parameters" element="ns0:poliss"/>
< /mes sage>
−
< portTy pe name="data_service_lapula_service.phpPortType">
−
< opera tion name="gettrxjual">
< inpu t message="tns:gettrxjual"/>
< outp ut message="tns:gettrxjualResponse"/>
< /ope ration>
< /portType>
−
< binding name="data_service_lapula_service.phpSOAPBinding" type="tns:data_service_lapula_service.phpPortType">
< s oap:binding transport="h t t p :// s chemas.xmlsoap.org/soap/ht tp" style="document"/>
−
< operatio n name="gettrxjual">
< soap :operation soapAction="h tt p: / /192.168.100.7:8901/data_service/l apula_service.php/gettrxjual" style="document"/>
−
< input>
< soap:body use="literal"/>
< /input>
−
< output>
< soap:body use="literal"/>
< /output>
< /operation>
< /binding>
−
< service name="data_service_lapula_service.php">
−
< port name="data_service_lapula_service.phpSOAPPort_Http" binding="tns:data_service_lapula_service.phpSOAPBinding">
< soap:address location="ht tp :/ /192.168.100.7:8901/data_service/lapula_service.php"/>
</ port>
</ service>
</ definitions>
and
this is my source code
Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import org.ksoap2.*;
import org.ksoap2.transport.*;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.xmlpull.v1.XmlPullParserException;
import java.util.Vector;
import java.io.IOException;
/**
* @author secangkirkopipanas
*/
public class gui_mobile3 extends MIDlet implements CommandListener, Runnable{
private Display display;
private String url = "htt p : //127.0.0.1/ data_service/lapula_service.php";
private TextBox textbox = null;
private Form form;
private TextField input;
private StringItem output;
private Command cmOk;
private Command cmExit;
public gui_mobile3() {
form = new Form("Mobile");
input = new TextField("No. Agen", "", 10, TextField.ANY);
output = new StringItem("","");
cmOk = new Command("OK", Command.OK,1);
cmExit = new Command("EXIT", Command.EXIT, 2);
form.append(input);
form.append(output);
form.addCommand(cmOk);
form.addCommand(cmExit);
form.setCommandListener(this);
}
public void startApp() {
display = Display.getDisplay(this);
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if(c==cmOk)
new Thread(this).start();
if(c==cmExit)
{
destroyApp(false);
notifyDestroyed();
}
//throw new UnsupportedOperationException("Not supported yet.");
}
public void run() {
try {
testWebService();
} catch (Exception ex) {
System.out.println(ex);
}
}
public void testWebService() throws Exception {
StringBuffer stringBuffer = new StringBuffer();
TextBox textBox = null;
String tem=null;
SoapObject resultsRequestSOAP = null;
String result = null;
// First WebService - echos name that is passed in, in this case 'Robertus Lilik Haryanto'
String method = "gettrxjual";
String namespace = "ht t p :/ /wso2.org/projects/wsf/php/ds";
String soapAction = "h ttp:// 19 2.168.100.7:8901/data_service/lapula_service.php/gettrxjual";
SoapObject client = new SoapObject(namespace , method);
client.addProperty("noagen1", "010300080");
client.addProperty("noagen2", "010300080");
client.addProperty("noagen3", "010300080");
client.addProperty("noagen4", "010300080");
// Creating the Soap Envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(client);
envelope.encodingStyle = SoapSerializationEnvelope.XSI;
HttpTransport transport = new HttpTransport(url);
transport.setXmlVersionTag("< ? xml version=\"1.0\" encoding=\"utf-8\"? >");
// Call the WebService
try {
transport.call(soapAction,envelope);
result = (envelope.getResult()).toString();
System.out.println("hasil : "+result);
} catch (XmlPullParserException ex) {
System.out.println(ex.getMessage());
output.setText(ex.getMessage());
} catch (IOException ex) {
output.setText(ex.getMessage());
} catch (Exception ex) {
output.setText(ex.getMessage());
}
stringBuffer.append(resultsRequestSOAP);
textBox = new TextBox("hasil ", stringBuffer.toString(), 4096, 0);
display.setCurrent(textBox);
}
}
i spent 2 weeks for this @_@
please help me
thanks
Last edited by akangbro : 11-19-2009 at 02:19 AM.
|
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|