开发者

Is it possible to read an answer before an exception?

开发者 https://www.devze.com 2023-02-21 22:20 出处:网络
I\'m working on a project where an android application is communicating with a PHP server (WAMP) where some methods are implemented. We\'re using XMLRPC to handle client calls to server\'s methods. An

I'm working on a project where an android application is communicating with a PHP server (WAMP) where some methods are implemented. We're using XMLRPC to handle client calls to server's methods. Anyway, even though everythi开发者_C百科ng happens fine, an exception is thrown when java tries to read the answer. So I would like to know if there is any way to read or save the server's response before java throws the exception (which is not really relevant) ?

Thanks in advance for your help !


The usual approach is to catch and handle this unchecked exception in your code. If you don't catch it, it will cause the application to stop.

Wrap the piece of code that causes the exception into a try/catch statement. This should allow you application to continue and you should be able to keep and process the response.


I do already set up a try/catch statement as you can see :

Integer result2 = null;
 try {
     Object[] dataParams = new Object[]{bytes, date, login};
     result2 = ((Integer) client.execute("storeData", dataParams)).intValue();
     System.out.println(result2.toString());
 } catch (Exception ex)
 {
     ex.printStackTrace();
 }

The storeData method is supposed to return an int. But as I get an exception, I can't see that response.

This is the error I get : [Fatal Error] :1:1: Content is not allowed in prolog.

I assume it's due to some bad characters in the xml response so that's why I'd like to get this response !

0

精彩评论

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

关注公众号