开发者

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜