Access java web service via ksoap2
Hi,
I have accessed a .Net web service using Http Request (via url) and that was pretty much easy. Now I need to access a java web service. I am not sure if I can use if via URL as I am not able to do that till now. Another option is to use ksoap2. Any idea about how can I proceed with that. I just need a good tutorial of information source as i am not able to find something relevant... All I can find is accessing .Net web service via Http Client. Hope to hear something great!!! |
Accessing .net service via http...
Quote:
Hi baran_khan, i see that you have accessed a .net web service using http request from your blackberry... could you please show me an example as to how exactly you did that. i have been trying to access a .net web service from my BB application which i have developed using blackberry JDE. so far i keep getting the error authentication required. my web service is in our corporate intranet. |
Its pretty straight forward....
First create class ConnectionThread.java and paste the following code in it.. PHP Code:
PHP Code:
|
Hi I use java web service and ksoap2.
So if you have any question, I will answer you as clearly as possible. But first tell me where you are for the moment |
Quote:
Thanks for the reply, As I have already posted some code, I am familiar with accessing the web service built in .Net. I am fairly new to ksoap2 and have already tried my hand on it. My few questions are: 1. Where can I get the preverified jar file for ksoap2. I downloaded this preverified jar from internet but for some reason it was giving error with org.ksoap.serialization package. 2. Secondly, if you can provide me with some sample that can give me an idea about how to approach it as presently I am not going anywhere with the things.... I am pretty much sure I am making a very small mistake ...thats what I usually do as major issues are easy to sort out... Hope to hear from you soon... |
First for the ksoap you just need the core and not the full version wich generate error when it's preverified.
And for the sample no problem You have to build your object using the soapObject structure and send them with the enveloppe. Code:
SoapObject request = new SoapObject(null, null); |
hi, thanks again for the reply, what about the preverified ksoap jar file...any chance you can send me that...I have already done this part but because the jar is not preverified, its giving the error. I have the core version of ksoap2
|
I have preverified the ksoap2.jar file using following command:
C:\Program Files\Research In Motion\BlackBerry JDE 4.0\bin>preverify -classpath "C:\Program Files\Research In Motion\BlackBerry JDE 4.0\lib\net_rim_api.jar" "D:\RIMClient\Standard\lib\kxmlrpc_full.jar" Once done that I have tried importing the org.ksoap2.* package but it still give the error...package does not exist. Any idea bout it...I have everything I can but without any thing positive |
have you added the ksoap as a library project and made your main project dependant on it?
|
Quote:
|
I just tried the code that baran_khan posted, but without success. Running in debug mode on the simulator the process simply stops during the http() method after it executes the line:
out.write(data.getBytes()); Any ideas why this might be happening? |
Preverified ksoap
1 Attachment(s)
Hi,
I have this preverified ksoap2, I have the same problems with the ksoap from the oficial page. I got this file from the forum, but I cannot find the original post. Hope it helps Regards! PD: rename .txt to .jar |
Quote:
By the looks of the thing you mentioned, I guess your app is not able to find the destination to contact with. |
Quote:
|
Problem in using Ksoap2 in my blackberry java application
I used Ksoap2 jar(ksoap2-j2me-core-2.1.2) in my project. I added this jar through a library project in my CLDC Application.
But when I try to debug the application on simulator, on launching the application error occured " Module Ksoap2 (jar file name) not found". Can anybody help me...... Basically I am stuck with how to access .net web service having user defined type as formal parameters, in my application, I used httpconnection with soapheader but still nt able to access web service. Please reply as early as possible..... |
Quote:
Along with adding the jar as a library project, you need to add it as a reference as well. I.e. in the project itself add this file as an external reference. The ksoap2.jar is supposed to be added twice, one via reference and second via library project. also please make sure that you have preverified version of ksoap2 jar. |
Quote:
|
How can I acces PHP wbservice from my Blackberry Application?
Pleas help he ... Here is a web service in php for sending email with attachments. How can I acces that webservice from my Blackberry phone. I am creating an Application which is using that php webservice for sending the mails.
|
You got multiple options for doing that.
First, you can use connectionmanager class for that. Second, The KSOAP library. please be very specific about what exactly you are looking for. Presently it is difficult for me to understand what you are looking for. Have you tried anything or are looking for clues. |
Hi Baran,
I assume that you've had a good experiece with BB development so far. I'm a dotnet developer new to Java and have been assigned to task to develop a BB Java project on my own. I've chosen KSoap2 ( or should I choose KSoap1 ? ) so far because my project requries allowing the end user to customize which web service URL to call. Since JSR172 uses static stubs this is not possible there. I'm pasting the code for a sample HelloWorld webservice call I have written using KSoap2. (I've followed your steps to add the ksoap jar to my lib) However, once the control reaches the ksoap_HelloWorld constructor it goes to NoSuchFile.java error page. Any idea what could be going wrong ? Code: public class ksoap_HelloWorld extends MIDlet implements CommandListener { private Form mainForm; private TextField symbolField; private StringItem resultItem; private Command getCommand; public ksoap_HelloWorld () { try { symbolField = new TextField ("Symbol", "IBM", 5, TextField.ANY); resultItem = new StringItem ("", ""); getCommand = new Command ("Get", Command.SCREEN, 1); mainForm.append (symbolField); mainForm.append (resultItem); mainForm.addCommand (getCommand); mainForm.setCommandListener (this); } catch(Exception e) { e.printStackTrace (); resultItem.setLabel ("Error:"); resultItem.setText (e.toString ()); } } public void startApp () { mainForm = new Form ("HelloWorld"); Display.getDisplay (this).setCurrent (mainForm); } public void pauseApp () { } public void destroyApp (boolean unconditional) { } public void commandAction (Command c, Displayable d) { try { String symbol = symbolField.getString (); resultItem.setLabel (symbol); // set up the variables String endPointURL = new String("[Web Service URL]"); String nameSpace = new String("[http//hello]"); String soapAction = new String("[http//hello]"); String urn = new String("urn:SAPService"); // create the envelope SoapObject soap = new SoapObject(urn, "HelloWorld"); soap.addProperty("name", symbol); // serialize the envelope SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.bodyOut = soap; // set up the transport HttpTransport ht = new HttpTransport(endPointURL); //make the call ht.call("", envelope); //get the response Object soapIn = envelope.getResponse(); // Do something with the response //outputForm.append("kSOAP response: " + soapIn.toString()); //display.setCurrent(outputForm); resultItem.setText("kSOAP response: " + soapIn.toString()); } catch (Exception e) { e.printStackTrace (); resultItem.setLabel ("Error:"); resultItem.setText (e.toString ()); } } /** for me4se */ public static void main (String [] argv) { ksoap_HelloWorld k1 = new ksoap_HelloWorld (); k1.startApp(); //new ksoap_HelloWorld ().startApp (); } } Looking forward to your help, Thanks a lot in advance!! Manhar. |
All times are GMT -5. The time now is 09:01 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.