我用 ksoap2 调用 1 个 web 服务:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidhttpTranport = new HttpTransportSE(URL,
ContantSystem.TimeOut);
androidhttpTranport.call(SOAP_ACTIONS, envelope);
Object responseBody = null;
try {
responseBody = envelope.getResponse();
} catch (SoapFault e2) {
}
try {
JSONObject json = new JSONObject(responseBody.toString());
} catch (JSONException e1) {
}
如果 webservice 的结果是 json(这个 json 有 6401728 个字符 'string(6401728)'
)。当我调用这个 web 服务时,我的应用程序死掉了。但是如果 webservice 的结果是 json ' string(2101728)
。我的应用程序运行正常。所以。我的代码中的错误在哪里?是什么导致了错误,是json的限制,webservice还是在哪里?如何解决这个问题?你能帮助我吗?谢谢。
例外:
11-07 19:54:41.283: E/AndroidRuntime(10620): FATAL EXCEPTION: Thread-1851
11-07 19:54:41.283: E/AndroidRuntime(10620): java.lang.OutOfMemoryError
11-07 19:54:41.283: E/AndroidRuntime(10620): at java.lang.String.<init>(String.java:432)
11-07 19:54:41.283: E/AndroidRuntime(10620): at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:642)
11-07 19:54:41.283: E/AndroidRuntime(10620): at java.lang.StringBuilder.toString(StringBuilder.java:663)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1419)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.kxml2.io.KXmlParser.next(KXmlParser.java:390)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.kxml2.io.KXmlParser.nextText(KXmlParser.java:2056)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.serialization.DM.readInstance(DM.java:34)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.serialization.SoapSerializationEnvelope.readInstance(SoapSerializationEnvelope.java:462)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:420)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:289)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:422)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:149)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195)
11-07 19:54:41.283: E/AndroidRuntime(10620): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
11-07 19:54:41.283: E/AndroidRuntime(10620): at jp.osaka.APPLIActivity.getMarterDB(APPLIActivity.java:408)
11-07 19:54:41.283: E/AndroidRuntime(10620): at jp.osaka.APPLIActivity.access$0(APPLIActivity.java:390)
11-07 19:54:41.283: E/AndroidRuntime(10620): at jp.osaka.APPLIActivity$myrunable.run(APPLIActivity.java:369)
11-07 19:54:41.283: E/AndroidRuntime(10620): at java.lang.Thread.run(Thread.java:856)