【问题标题】:Android couldnot parse http response where as iphone canAndroid 无法解析 http 响应,而 iphone 可以
【发布时间】:2013-07-22 22:04:34
【问题描述】:

在 android 和 iPhone 使用相同的 webservices 时,iPhone 可以成功解析响应,而 android 失败。

登录 android 说

07-23 17:14:10.121: I/com.android.cashww.terminal.webservice.Webservice(2668): Code:200
07-23 17:14:10.175: I/com.android.cashww.terminal.webservice.Webservice(2668): �_�������?D&M�¶�g���K'��>K�<��
07-23 17:14:10.175: I/com.android.cashww.terminal.webservice.Webservice(2668): �R���CJ���~m�e�c���������Z�%�h;�<F+�������������a�@���GF7R��ۣ�N��Bq�����S��%�=����I,�,Ϲj%mra;��:����+�_��+bO��H4ܣ�>�\�����EC��O-vY\X�F|!�pM�6tò�&��x�M3��i7b�ϷG,�eb!�J������D��`7��D�;[ʯ�.&
07-23 17:14:10.175: I/com.android.cashww.terminal.webservice.Webservice(2668): ����wy�X�7�G|���<9#l<a{d�$j�ۢ!Qn�ǴCׅ[w5�,�x�"�7�qϧ�{d�]3B6f�z�un�����,ŴM-�

但期望 xml 响应

安卓代码:

String cset = EntityUtils.getContentCharSet(entity);
ret = EntityUtils.toString(entity,cset);

还有一件事:我在 apache 中启用了 mod_deflate 过滤器

<IfModule mod_deflate.c>
 SetOutputFilter DEFLATE

 SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary

 Make proxies work as they should.
 <IfModule mod_headers.c>
 Header append Vary User-Agent
 </IfModule>

【问题讨论】:

    标签: java android http servlets


    【解决方案1】:

    如果没有完整的代码就无法解决您当前的问题,我强烈建议您使用https://github.com/octo-online/robospice,它不仅会为您处理所有事情,它还增加了缓存和其他功能

    【讨论】:

      猜你喜欢
      • 2018-06-29
      • 2019-03-16
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多