Tuesday 21 February 2012

MIDLET TO ACCESS XML-WEBSERVICE using KSOAP

yesterday(19.2.2012)  I did a simple  example for consuming
webservice in midlet using  ksoap.

  ksoap made consuming webservice as an easiest  thing.
I  wanted ksoap1  jar I googled as  "ksoap  for  j2me"
then I got   "ksoap2.sourceforge.net/"
from this page I found  the line

" kSOAP1 is deprecated and archived at ksoap.objectweb.org
 (thanks to the objectweb.org team for keeping the kSOAP 1 pages
 after the merger with enhydra.org)."

Then I went to 'download  section' on that page itself.

There I found this link

  http://ksoap.objectweb.org/software/downloads/

where  I got the  ksoap-midp.zip

   just  paste that zip  file  in  c:\wtk104\apps\srm\lib.  (here srm is my application's name)

In midlet  code 3 lines are most  important to webservice,

 That  is,

     SoapObject  ob=new  SoapObject("","sayhello");

     ob.addProperty("a",s1);
   
     HttpTransport   transport=new    HttpTransport(url,"");

  here  'sayhello'  is  the function name and 'a'
is  parameter  name.

  To use these 2 classes  (SoapObject  and  HttpTransport) we need to import  ksoap  package.

import  org.ksoap.*;
import  org.ksoap.transport.*;



  Then my webservice  application  got run successfully!

 I have given detailed code in my  website.