BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   **** BlackBerry and Ksoap2 Tutorial ***** (http://www.blackberryforums.com/developer-forum/155972-blackberry-ksoap2-tutorial.html)

sickned 10-22-2008 09:31 AM

**** BlackBerry and Ksoap2 Tutorial *****
 
1 Attachment(s)
I was very, very sick trying to make work the ksoap2's libraries at a BlackBerry app and now I get it, Im gonna make a tutorial for all the people at the forum that have the same problem I had.

Ive used Eclipse and the Blackberry JDE plugin.

First of all, download the ksoap2 library preverified. I've uploaded it in this post.

Then, follow the steps:

- Create a Blackberry library project in your workspace, Ksoap2. (Create a new project->Right click->Project Properties-> Blackberry Project Properties-> Application->Project type->Library
- Create a folder called "lib" at this new library project.
- Copy the ksoap2 preverified at this post to the lib folder. Right click at Eclipse and select "Add to build path".
- Right click on the project->Add file to Blackberry Project-> Select the ksoap2 jar from the "lib" folder.

Now, into your project, in which you wanna use ksoap, do the next:
- Right click on the project -> Properties -> Java Build Path -> Libraries -> Add Jars... select Ksoap2.jar (Project's jar NOT LIBRARY JAR).. ->Ok
- Right click on the project -> Properties -> BlackBerry Project Dependencies -> Select "Ksoap2".

WARNING!!
Sometimes when you add a new library or change something in the build path, you must repeat the last step, because this checkbox get unchecked.

Now, you're ready to write your code.

I've uploaded a simple code sample calling a web service.

I hope this could be useful.

Change: I've re-uploaded the file, because it looks like be corrupted.

ArthurKnight 10-22-2008 06:13 PM

Quote:

Originally Posted by sickned (Post 1144249)
I was very, very sick trying to make work the ksoap2's libraries at a BlackBerry app and now I get it, Im gonna make a tutorial for all the people at the forum that have the same problem I had.

Ive used Eclipse and the Blackberry JDE plugin.

First of all, download the ksoap2 library preverified. I've uploaded it in this post.

Then, follow the steps:

- Create a Blackberry library project in your workspace, Ksoap2.
- Create a folder called "lib" at this new library project.
- Copy the ksoap2 preverified to this post. Right click at Eclipse and select "Add to build path".

Now, into your project, in which you wanna use ksoap, do the next:
- Right click on the project -> Properties -> Java Build Path -> Libraries -> Add Jars... select Ksoap2.jar. ->Ok
- Right click on the project -> Properties -> BlackBerry Project Dependencies -> Select "Ksoap2".

WARNING!!
Sometimes when you add a new library or change something in the build path, you must repeat the last step, because this checkbox get unchecked.

Now, you're ready to write your code.

I've uploaded a simple code sample calling a web service.

I hope this could be useful.

Great Example, just what I needed and I think many people need right now!

Thanks for your contribution :smile:

pmardones 10-27-2008 09:07 AM

can't see the tag BB project dependencies
 
i followed the instructions, but i can't see the tag BlackBerry Project Dependencies. I'm using eclipse 3.4, jde 4.6 and your ksoap2 library.

Pls Help :(

bsecurity 11-13-2008 09:59 PM

great jobs!

jacytan 11-19-2008 03:33 AM

Hi,

I'm using ksoap2 library and i want to use the class HttpTransportBasicAuth.

I understand that this class is not included in the preverified core ksoap2 library provided above.

It is in a separate file called ksoap-extras-2.1.2.jar or something like that, that i downloaded from sourceforge.net

I want to use this class in order to authenticate the user trying to access the web service by providing a username and password. I tried to verify this library but it always fails.

Can somebody help me on what i should do? Please help!



Thanks,
Jaclyn

sickned 11-19-2008 10:01 AM

Quote:

Originally Posted by jacytan (Post 1174482)
Hi,

I'm using ksoap2 library and i want to use the class HttpTransportBasicAuth.

I understand that this class is not included in the preverified core ksoap2 library provided above.

It is in a separate file called ksoap-extras-2.1.2.jar or something like that, that i downloaded from sourceforge.net

I want to use this class in order to authenticate the user trying to access the web service by providing a username and password. I tried to verify this library but it always fails.

Can somebody help me on what i should do? Please help!



Thanks,
Jaclyn

Just open the JAR I posted with WinRar and add the HttpTransportBasicAuth.class on the right package. It worked for me!

jacytan 11-21-2008 11:40 PM

Quote:

Originally Posted by sickned (Post 1174651)
Just open the JAR I posted with WinRar and add the HttpTransportBasicAuth.class on the right package. It worked for me!

Thanks so much for the reply! it really helped! :)

I was able to run my application already! :)

bharath001 11-25-2008 04:31 PM

Still no luck
 
First of all, thanks for the tutorial and it gives us a starting point. I have been looking at this for a week now and I still can not get it to work. I can not see "Blackberry project dependencies" and "Add file to project" options. Am I doing something wrong?



Quote:

Originally Posted by sickned (Post 1144249)
I was very, very sick trying to make work the ksoap2's libraries at a BlackBerry app and now I get it, Im gonna make a tutorial for all the people at the forum that have the same problem I had.

Ive used Eclipse and the Blackberry JDE plugin.

First of all, download the ksoap2 library preverified. I've uploaded it in this post.

Then, follow the steps:

- Create a Blackberry library project in your workspace, Ksoap2. (Create a new project->Right click->Project Properties-> Blackberry Project Properties-> Application->Project type->Library
- Create a folder called "lib" at this new library project.
- Copy the ksoap2 preverified at this post to the lib folder. Right click at Eclipse and select "Add to build path".
- Right click on the project->Add file to Blackberry Project-> Select the ksoap2 jar from the "lib" folder.

Now, into your project, in which you wanna use ksoap, do the next:
- Right click on the project -> Properties -> Java Build Path -> Libraries -> Add Jars... select Ksoap2.jar (Project's jar NOT LIBRARY JAR).. ->Ok
- Right click on the project -> Properties -> BlackBerry Project Dependencies -> Select "Ksoap2".

WARNING!!
Sometimes when you add a new library or change something in the build path, you must repeat the last step, because this checkbox get unchecked.

Now, you're ready to write your code.

I've uploaded a simple code sample calling a web service.

I hope this could be useful.

Change: I've re-uploaded the file, because it looks like be corrupted.


sickned 12-01-2008 06:21 AM

Quote:

Originally Posted by bharath001 (Post 1183186)
First of all, thanks for the tutorial and it gives us a starting point. I have been looking at this for a week now and I still can not get it to work. I can not see "Blackberry project dependencies" and "Add file to project" options. Am I doing something wrong?

Are you using Eclipse or JDE? This tutorial is for Eclipse, I dont know how to do some steps at JDE.

mithleshdwivedi 12-05-2008 12:03 AM

hey sorry to say m new in this using Ksoap bt i have to do a project in this .
 
m using ksoap jar file and eclips bt cann't do that ...the library is not supported ...
could u explain me ...previously i have wrked on banking project so m totally blank in using ksoap with blackberry IDE ....

plz give me some detail of this .....i used eclips earlier bt can't understand how to relate IDE and eclips plugin .......thanks in advance

baran_khan 12-05-2008 12:22 AM

Quote:

Originally Posted by mithleshdwivedi (Post 1197070)
m using ksoap jar file and eclips bt cann't do that ...the library is not supported ...
could u explain me ...previously i have wrked on banking project so m totally blank in using ksoap with blackberry IDE ....

plz give me some detail of this .....i used eclips earlier bt can't understand how to relate IDE and eclips plugin .......thanks in advance

Please confirm if the jar u are using is ksoap or ksoap2. You need to have a preverified version of ksoap2 jar file.

mithleshdwivedi 12-05-2008 12:38 AM

hi
 
ksoap2-j2me-core-prev-2.1.2

sir m using ksoap2 preverified jar....kindly help
and thanks for ur post

baran_khan 12-05-2008 12:40 AM

Quote:

Originally Posted by mithleshdwivedi (Post 1197088)
ksoap2-j2me-core-prev-2.1.2

sir m using ksoap2 preverified jar....kindly help
and thanks for ur post

I have sent you an email with the basic environment configuration steps ..let me know if you need further assistance.

mithleshdwivedi 12-05-2008 01:05 AM

hi
 
thanku sir yes m working in qbit systems in jaipur ...
m reading the link provided by u ..thanks once again sir

my_aro 12-05-2008 04:36 AM

KSOAP problem
 
i had tried KSOAP2 to run on a Blackberry JDE4.6 but it didnt work fine for me,

i have this code:



SoapObject myObject = new SoapObject("http:--ws.test.net", "stringConcat");
HttpTransport transport = new HttpTransport("http:--localhost: 8080-BlackberryWS-BlackberryService");

myObject.addProperty("fname", "my");
myObject.addProperty("lname", "test");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.setOutputSoapObject(myObject);


transport.debug = true;

transport.call("stringConcat", envelope);

String data = envelope.getResponse().toString();

but
DataGramProtocol(ConnectionBase).recieve(DataGram) Source not found problem pops up upon Debug. and as i look at the variables this._connectionHandlerName = "httpc"
and this._name = //localhost:8080/BlackberryWS/BlackberryService;ConnectionHandler=httpc


but with KSOAP2 SE:

the code works fine changing

HttpTransport transport = new HttpTransport("http:--localhost: 8080/ BlackberryWS/ BlackberryService");

to

HttpTransportSE transport = new HttpTransportSE("http:--localhost:8080/BlackberryWS/BlackberryService");

meaning with blackberry it changes http to httpc.. how can i make it maintain in http?


can anybody help? please..

manyguns 12-11-2008 01:51 AM

I am running into the same problem with not seeing "Blackberry project dependencies" under the project options. Anybody have any ideas?

baran_khan 12-11-2008 03:17 AM

Quote:

Originally Posted by manyguns (Post 1204712)
I am running into the same problem with not seeing "Blackberry project dependencies" under the project options. Anybody have any ideas?

Under the blackberry Project Properties section, click on "Application" tab and change your project type to Library.

manyguns 12-11-2008 08:40 AM

Quote:

Originally Posted by baran_khan (Post 1204731)
Under the blackberry Project Properties section, click on "Application" tab and change your project type to Library.

I'm assuming you mean to do that for the project that I made as instructed by the tutorial and not for the actual project that shows the UI. I have done that. The problem is I do not see "Blackberry project dependencies" at all in the properties list for either of the projects. I see...
Resources
Blackberry Project Properties
Builders
Java Build Path
etc...

Meenal 12-13-2008 02:31 AM

testing webservice on simulator
 
Hi All,
I have developed a client on BB using ksoap2.

I have tried using the MDS simulator along with the device simulator (as mentioned in some post), but whenever i send a request, i get the following Exception:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://www.w3.org/2003/05/soap-envelope}soap:Envelope>@1:205 in java.io.InputStreamReader@2bdcc2b0)

I dunno whats going wrong or how to go about it. Please help.

I am developing using the following components:
BB OS: 4.1.0
JDE: 4.1.0
ksoap2: lib\ksoap2-j2me-core-prev-2.1.2.jar

PS: I can access it through http demo application, but not through my web service. I am pasting my code below:

Code:

    private String IPorHostname = "http://192.168.1.33";
    private String path = "/xyzs/service.asmx";
    public MXYZ_Main() {

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

        request.addProperty("dlr_code", "1177");
        System.out.println(request.toString());

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.bodyOut = request;
        envelope.dotNet = true;

        HttpTransport ht = new HttpTransport(IPorHostname + path);
        ht.debug = true;

        try {
            ht.call("", envelope);
           
            SoapObject result = (SoapObject) envelope.getResponse();
           
            System.out.println(result.toString());
            String str = result.getProperty("DealerOutstandingResult").toString();
         
            System.out.println("Soap: " + str);
        } catch (XmlPullParserException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (Exception ex) {
            System.out.println("ex " + ex.toString());
        }


Meenal 12-13-2008 05:35 AM

Hi all,
I have solved the above problem.


All times are GMT -5. The time now is 08:01 PM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.