Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 30
Registered: ‎09-20-2012
My Device: BlackBerry Curve 8330
My Carrier: vodafone

getting error while using KSoap Parsing.

[ Edited ]

Hi All,

          I am new to Blackberry Development and previously i have experience on android developement. I am doing sample example on KSoap parsing in blackberry. i integrated the code in my application and also added jar file for ksoap. but when i am trying to open the app in device or emulator i am getting this error.

"error starting KSoapDemo: Module 'ksoap2-j2me-core-2.12' not found." I attached my source code.

 

String serviceUrl = "http://xxxxxxxxxxxxxxxx.asmx";

String serviceNameSpace = "http://tempuri.org/";
String soapAction = "http://tempuri.org/GetConsumerLoginValidate";
String methodName = "LoginCheck";
SoapObject rpc = new SoapObject(serviceNameSpace, methodName);
rpc.addProperty("UserName".trim(), username.trim());
rpc.addProperty("Password".trim(), password.trim());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;// <strong>IF you are accessing .net based web
// service this should be true</strong>
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
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);
// Dialog.inform(ht.responseDump);
// result = (envelope.getResponse()).toString();
result = (envelope.getResult()).toString();
SoapObject body = (SoapObject) envelope.bodyIn;

result = (String) body.getProperty("NewDataSet").toString();

System.out.println("Result is: " + result);

//Dialog.inform(result);

} catch (org.xmlpull.v1.XmlPullParserException ex2) {
//Dialog.inform(ex2.getMessage());
ex2.printStackTrace();
} catch (Exception ex) {
//Dialog.inform(ex.getMessage());
ex.printStackTrace();
}

 

If any body knows the solution means then plz tell the answer,, 

 

Thanks and Regards,

SatyaSeshu..........

 

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: getting error while using KSoap Parsing.

you can either mark the ksoap2 jar as export (project properties, java build path, order and export, check ksoap2) or load a ksoap2 cod file on the device.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: getting error while using KSoap Parsing.

[ Edited ]

hi

Do one thing,

1) select the project. do right click. and point to properties.

2) Now, Click on Order and Export tab.

3) here make sure the jar is check or not. if that jar file is not checked. then please checked it.

Thanks

New Developer
Posts: 30
Registered: ‎09-20-2012
My Device: BlackBerry Curve 8330
My Carrier: vodafone

Re: getting error while using KSoap Parsing.

Thanks Simon and pankaj for replying to me. I checked the ksoap jar file whar u have mention and i run the application. now i am getting these error.

 

"Packaging project KSoapEx

C:\Eclipse\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.36\components\bin\rapc.exe -convertpng -quiet codename=deliverables\Standard\5.0.0\KSoapEx -sourceroot=D:\MobileApps\BlackberryApps\KSoapEx\src;D:\MobileApps\BlackberryApps\KSoapEx\res -import=C:\Eclipse\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.36\components\lib\net_rim_api.jar E:\Blackberry libraries\ksoap2-j2me-core-2.1.2.jar deliverables\Standard\5.0.0\KSoapEx.rapc D:\MobileApps\BlackberryApps\KSoapEx\bin
org.ksoap2.SoapEnvelope: Error!: Missing stack map in: <init> at label: 30
Packaging project KSoapEx failed (took 3.747 seconds)"

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: getting error while using KSoap Parsing.

did you preverify the jar?
see
http://docs.blackberry.com/en/developers/deliverables/11938/Preverify_a_BlackBerry_Java_Application_...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: getting error while using KSoap Parsing.

HI

 

Try this jar file. it might be version problem. test this one. 

 

Thanks

New Developer
Posts: 30
Registered: ‎09-20-2012
My Device: BlackBerry Curve 8330
My Carrier: vodafone

Re: getting error while using KSoap Parsing.

Thanks for replying to me.. I attached new jar file and now i am not getting any error but when i call the soap function i am getting crash...

see the code attached here

 

boolean ans = false;
String result = null;
SoapObject request = new SoapObject("http://tempuri.org/","LoginCheck");
request.addProperty("username",username);
request.addProperty("password",password);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
envelope.dotNet = true;
HttpTransport ht = new HttpTransport("xxxxxxxxxxxxxxxxxxx.asmx");
ht.debug = true;
try {
ht.call("http://tempuri.org/GetConsumerLoginValidate", envelope);
// if((envelope.getResponse().toString()).equals("true")){
// return true;
// }
SoapObject body = (SoapObject) envelope.bodyIn;
result = (String) body.getProperty("NewDataSet").toString();
System.out.println("Result is: " + result);
}
catch (XmlPullParserException ex) {
Dialog.alert("ex1 "+ex.toString() );
ex.printStackTrace();
} catch (IOException ex) {
Dialog.alert("ex2 " +ex.toString());
ex.printStackTrace();
} catch (Exception ex) {
Dialog.alert("ex3 " + ex.toString());
}
return ans;

 

i am getting crash at ht.call(); i.e., highlighted with red color. Can i know the reason plz

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: getting error while using KSoap Parsing.

just as a sidenote:
dialog.alert does not work unless you execute this on the event thread, and you should never do networking on the event thread.
see http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865

what do you mean with "crash"?
as pointed out above, your exception handling is faulty. also take note that exceptions never have a stacktrace on BB, you have to catch throwable for that.

check the device event log (alt+lglg) for any exceptions.

also helpful are eclipse exception breakpoints.

from your android comment i guess you already tested the ksoap code? otherwise i suggest that you use JUnit (+httptransportSE) to test your webservice, tcpmon is also helpful.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: getting error while using KSoap Parsing.

Hi

 

There is an issue in your soap action.

 

check your Soap_Action value

 

Thanks

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: getting error while using KSoap Parsing.

Hi

SoapObject request = new SoapObject("http://tempuri.org/","LoginCheck");

here you tell that your method name is LoginCheck. and again in you says ur method name is "GetConsumerLoginValidate".

As you have put in ur example.

ht.call("http://tempuri.org/GetConsumerLoginValidate", envelope);

So, do confirm you method name. and put the same method name in both place. then it will work fine.

Thanks