DEVANG SHARMA
DEVANG SHARMA

Reputation: 2662

Application close unexpectedly after calling web service if result is null

i use the following lines in my program to call web service and taking the result

all thing is fine, but if any time if a web page has no content it has null or white space then application close unexpectedly.

           1) SoapPrimitive result=null;
           2) androidHttpTransport.call(SOAP_ACTION, envelope);
               //upto this line program run smoothly
           3) result = (SoapPrimitive)envelope.getResponse();

plz suggest me, how i handle this, because i can only check the result value after completion of 3 line, but error occur before completion of line number 3.

i checked the envelop before result =(SoapPrimitive)envelope.getResponse(); but it not have any null, but i have still same problem

waiting for reply

Upvotes: 1

Views: 398

Answers (2)

Deepak Rohilla
Deepak Rohilla

Reputation: 95

You should check for null. and if null happen than create a new object and pass some default value or anyting like that. You can than detect that null value and can handle in code.

don't try to handle it by "try catch" becouse it is very costly in mobile application.

Upvotes: 1

Olegas
Olegas

Reputation: 10517

May be your envelope is just null. Check it before doing anything with it.

Upvotes: 2

Related Questions