我正在使用Ksoap2
库进行Web服务,并使用kvmserializable
将复杂参数传递给Web服务m。
我得到了这个例外
05-13 13:38:00.644: W/System.err(26739): SoapFault - faultcode: 'SOAP-ENV:Server' faultstring: 'Error Type: SYSTEM NOTICE,
05-13 13:38:00.644: W/System.err(26739): Error Description: Undefined index: project' faultactor: 'null' detail: null
05-13 13:38:00.644: W/System.err(26739): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:147)
05-13 13:38:00.655: W/System.err(26739): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
05-13 13:38:00.655: W/System.err(26739): at org.ksoap2.transport.Transport.parseResponse(Transport.java:118)
05-13 13:38:00.685: W/System.err(26739): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:275)
05-13 13:38:00.724: W/System.err(26739): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118)
05-13 13:38:00.724: W/System.err(26739): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:113)
05-13 13:38:00.734: W/System.err(26739): at com.example.login2.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:86)
05-13 13:38:00.784: W/System.err(26739): at com.example.login2.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:1)
05-13 13:38:00.821: W/System.err(26739): at android.os.AsyncTask$2.call(AsyncTask.java:185)
05-13 13:38:00.821: W/System.err(26739): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
05-13 13:38:00.858: W/System.err(26739): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
05-13 13:38:00.858: W/System.err(26739): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
05-13 13:38:00.894: W/System.err(26739): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
05-13 13:38:00.894: W/System.err(26739): at java.lang.Thread.run(Thread.java:1019)
05-13 13:38:00.924: E/ErrorResp:(26739): SoapFault - faultcode: 'SOAP-ENV:Server' faultstring: 'Error Type: SYSTEM NOTICE,
05-13 13:38:00.924: E/ErrorResp:(26739): Error Description: Undefined index: project' faultactor: 'null' detail: null
我搜索了很多但找不到任何解决方案,请解释为什么会出现此错误以及出错的原因。请帮忙。
答案 0 :(得分:0)
使用新版本的ksoap2 :( http://code.google.com/p/ksoap2-android/)
private SoapObject getSoapResponse(SoapObject request, String url, String soapAction) {
Log.d(TAG, "inside getSoapResponse");
SoapObject response = null;
try {
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
Marshal dateMarshal = new MarshalDate();
dateMarshal.register(envelope);
MarshalFloat floatMarshal = new MarshalFloat();
floatMarshal.register(envelope);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(url);
androidHttpTransport.call(soapAction, envelope);
response = (SoapObject)envelope.bodyIn;
} catch (SoapFault sfe) {
Log.d(TAG, " SoapFault ");
sfe.printStackTrace();
} catch (IOException ioe) {
Log.d(TAG, " IOException ");
ioe.printStackTrace();
} catch (XmlPullParserException xppe) {
Log.d(TAG, " XmlPullParserException ");
xppe.printStackTrace();
}
return response;
}
也用于请求:
SoapObject request = new SoapObject(namespace, method);
PropertyInfo name = new PropertyInfo();
name.setName(RequestInfo.PROPERTY_LOGIN_TYPE);
name.setValue("jhon");
name.setType(String.class);
request.addProperty(name);
PropertyInfo location = new PropertyInfo();
location.setName("Bangalore");
location.setValue(facebookUserName);
location.setType(String.class);
request.addProperty(location);
SoapObject response = getSoapResponse(request, url, soap_action);
if (response != null) {
//parse the XML file here.
}
答案 1 :(得分:0)
我找到了解决问题的方法。
实际上我没有传递项目字段的参数。 项目领域是强制性的。 :)