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

New Developer
Posts: 20
Registered: ‎06-08-2009
My Device: Not Specified

Web service connection

[ Edited ]


I am developing an application that consumes a Web Service, use HttpConnection Connector.open () and send the parameters through the model "GET", but the connexion is broken very easily, it is best to use ksoap or is there some other suggestions to make this? this is a bit of code to determine when the connection is broken,



public static InputStream SetConnection(String url){


        HttpConnection conn = null;        

        int responseCode;

        InputStream is = null;               


                conn = (HttpConnection) Connector.open(url+";deviceside=true");                


                responseCode = conn.getResponseCode();                

                if (responseCode != HttpConnection.HTTP_OK) {                      

                    is = null;

                }else {                                       

                    is = conn.openInputStream();


         } catch(Exception ex){             


         return is;



InputStream is = SetConnection("http://sales........./UserValidate?_user=" + _responseUser + "&_password=" + _responsePassword);            

  if(is == null)  


       Application.getApplication().invokeLater(new Runnable() {

                    public void run(){  

                                    Dialog.alert(" conexion ERROR");                  


               } );

         } else   

              Application.getApplication().invokeLater(new Runnable() {

                    public void run(){  

                                    Dialog.alert("conexion OK");                  


               } );



Regular Contributor
Posts: 67
Registered: ‎08-16-2011
My Device: 7185
My Carrier: Reliance

Re: Web service connection

ksoap is best Smiley Happy


i did its work very good but i am having problem in authentication only if your web service does not require http basic authentication then ksop is very good


Smiley Happy


Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Web service connection

ksoap2 works pretty good for most webservices and has some advantages over stubs, but it is more difficult to set up than stubs.
you can find some resources for both by doing a search on the forum.

basic auth also works with ksoap2.
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
Posts: 21
Registered: ‎02-21-2012
My Device: Blackberry 8520
My Carrier: T-Mobile

: Web service connection


String ServiceConnect(){


String response=



String serviceUrl=



String serviceNamespace =


String soapAction =




SoapObject rpc =

new SoapObject(serviceNamespace,"GetQuote");




SoapSerializationEnvelope envelope =

new SoapSerializationEnvelope(SoapEnvelope.VER11);


bodyOut= rpc;


dotNet = true;


HttpTransport ht =



debug = true;






response = (envelope.getResponse()).toString();




catch(Exception ex)


response = ex.toString();




// add(new EditField("RESULT:",response));returnresponse;


Posts: 21
Registered: ‎02-21-2012
My Device: Blackberry 8520
My Carrier: T-Mobile

Re: : Web service connection

proper working code