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 Contributor
Posts: 6
Registered: ‎04-16-2012
My Device: 9930
My Carrier: Blackberry

can not connect to web service

Hello  friends,

I am new to blackberry developement.

nowadays i am developing one demo which consumes the web service.

my web service is deployed on localhost.

for the web service access, i use the ksoap2 jar.

but when i run the application from simulator, its giving me the error of Local connection time out after 120000~

any suggestions would be appreciated.

Thanks..

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

Re: can not connect to web service

welcome to the support forums.

there are several possible issues:
- localhost is not supported by the simulator, you can use the ip address of your computer (not 127.0.0.1)
- you did not specify deviceside=true AND did not launch the MDS simulator
- several other possible venues, but the above are the most likely ones.
----------------------------------------------------------
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
New Contributor
Posts: 6
Registered: ‎04-16-2012
My Device: 9930
My Carrier: Blackberry

Re: can not connect to web service

hii following is my code where i need to write deviceside=true???

 

final String SOAP_ACTION = "";
            final String METHOD_NAME = "getAllCompany";            
            final String NAMESPACE = "http://services.master.ndil.com/";
            final String URL = "http://10.112.99.30:8080/MasterServiceService/MasterService?wsdl";
            SoapObject resultRequestSOAP = null;
            int msg=-1;
                
                                    
            //AndroidHttpTransport androidHttpTransport =   new AndroidHttpTransport(URL);
            HttpTransport ht = new HttpTransport(URL);
            try {
                EventLogger.logEvent(Guid.eventLogId,"####### Enter WS Call..".getBytes());
                SoapObject request = new SoapObject(NAMESPACE,  METHOD_NAME);
                // Add the input required by web service
               // request.addProperty("input", searchNameString);
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                //envelope.setOutputSoapObject(request);
                
                envelope.bodyOut=request;
                envelope.dotNet = false;
                envelope.encodingStyle = SoapSerializationEnvelope.ENC;
                
                EventLogger.logEvent(Guid.eventLogId,"####### Make WS Call..".getBytes());
                // Make the soap call.
                ht.call(SOAP_ACTION, envelope);
                ht.debug=true;
                EventLogger.logEvent(Guid.eventLogId,"#######  WS Called..".getBytes());
                msg=0;
                // Get the SoapResult from the envelope body.
                resultRequestSOAP = (SoapObject) envelope.bodyIn;

                SoapObject nameResult = (SoapObject) resultRequestSOAP.getProperty(0);
                String log="#######  Count "+nameResult+" ........";
                EventLogger.logEvent(Guid.eventLogId,log.getBytes());
                int count = nameResult.getPropertyCount();
                System.out.println("Property Count is : " + count);
                msg=count;
               
            } catch (IOException e) {
                // TODO Auto-generated catch block
                EventLogger.logEvent(Guid.eventLogId, ("######### Error : "+ e.getMessage()).getBytes());
                e.printStackTrace();
        } catch (XmlPullParserException e) {
                // TODO Auto-generated catch block
            EventLogger.logEvent(Guid.eventLogId, ("######### Error : "+ e.getMessage()).getBytes());
                e.printStackTrace();
        } 

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

Re: can not connect to web service

you can use http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/io/transport/ConnectionFactory... to create the correct URL.

This should help you understand the issue:
http://supportforums.blackberry.com/t5/Java-Development/Networking-Transports-II/ta-p/446742?name=Ne...

basically you should be fine if you start the MDS simulator together with the BB simulator, but it is important to understand how networking works on the BB platform.
----------------------------------------------------------
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
New Contributor
Posts: 6
Registered: ‎04-16-2012
My Device: 9930
My Carrier: Blackberry

Re: can not connect to web service

hii simon,

the issue is resolved by using deviceside=true and interface=wifi..

now i can access my web service..

thanks for your help.

can u tell me what exactly deviceside=true and interface=wifi do??  what do they mean by??

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

Re: can not connect to web service

watch the video i linked above, that should resolve your questions.
(in short, they tell the device which route to take to connect)
----------------------------------------------------------
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