这是我构建我的 Kosap 请求 XML 的方式:
public static SoapSerializationEnvelope constructEnvelope (String METHOD_NAME, List<NameValuePair> properties) {
SoapObject request = new SoapObject(Constants.NAMESPACE, METHOD_NAME);
if (null != properties && !properties.isEmpty() && properties.size() > 0) {
for (NameValuePair prop : properties) {
request.addProperty(prop.getName(), prop.getValue());
}
}
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
if (null != properties && !properties.isEmpty() && properties.size() > 0) {
envelope.addMapping(Constants.NAMESPACE, METHOD_NAME, request.getClass());
}
return envelope;
}
堆栈跟踪 :
04-08 16:46:42.292: WARN/System.err(19812): java.lang.NullPointerException
04-08 16:46:42.292: WARN/System.err(19812): at org.ksoap2.transport.ServiceConnectionSE.getResponseProperties(ServiceConnectionSE.java:85)
04-08 16:46:42.292: WARN/System.err(19812): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:189)
04-08 16:46:42.292: WARN/System.err(19812): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)
04-08 16:46:42.292: WARN/System.err(19812): at com.cantorfuturesexchange.CantorBinaryOptions.ui.LogInActivity$PracticeRegistration.doInBackground(LogInActivity.java:665)
04-08 16:46:42.292: WARN/System.err(19812): at com.cantorfuturesexchange.CantorBinaryOptions.ui.LogInActivity$PracticeRegistration.doInBackground(LogInActivity.java:623)
04-08 16:46:42.292: WARN/System.err(19812): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-08 16:46:42.292: WARN/System.err(19812): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-08 16:46:42.302: WARN/System.err(19812): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-08 16:46:42.302: WARN/System.err(19812): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
04-08 16:46:42.302: WARN/System.err(19812): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
04-08 16:46:42.302: WARN/System.err(19812): at java.lang.Thread.run(Thread.java:856)
04-08 16:46:42.342: ERROR/MP-Decision(1576): UP Ld:55 Nw:1.990000 Tw:140 rq:2.800000 seq:147.000000
04-08 16:46:42.793: ERROR/MP-Decision(1576): DOWN Ld:18 Ns:1.100000 Ts:190 rq:0.000000 seq:197.000000
04-08 16:46:43.574: WARN/PowerManagerService(718): Timer 0x7->0x3|0x0
研究工作:
按照以下链接中的说明更改我的信封创建: HttpTransportSE.call 方法经常返回 NullPointerException
public static SoapSerializationEnvelope constructEnvelope (String METHOD_NAME, List<NameValuePair> properties) {
SoapObject request = new SoapObject(Constants.NAMESPACE, METHOD_NAME);
if (null != properties && !properties.isEmpty() && properties.size() > 0) {
for (NameValuePair prop : properties) {
PropertyInfo property = new PropertyInfo();
{
property.name = prop.getName();
property.setNamespace(Constants.NAMESPACE);
property.setValue(prop.getValue());
}
request.addProperty(property);
}
}
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
if (null != properties && !properties.isEmpty() && properties.size() > 0) {
envelope.addMapping(Constants.NAMESPACE, METHOD_NAME, request.getClass());
}
return envelope;
}
我什至发现很少有其他链接,我已经尝试过使用 Ksoap 3.0.0 版而不是 3.0.0-rc4 版,但没有任何效果。我什至找到了一个链接,其中说明了有关检查基础知识的内容,但我无法理解如何解决该问题。下面是那个链接。