使用 ksoap2 lib 从 android 调用 .net SOAP1.1 Web 服务我遇到了将响应转换为自定义对象的问题。例如下面的代码在 httpTransport.call(soapAction, soapEnvelope); 之后被正确调用。并且里面有数据。但是正如我在几个示例中看到的那样,我不能将它转换为特定对象,也不能转换为 SoapObject 或 Vector,我得到 CastException 或什么都没有。如果有人知道如何处理它,请帮助。
public StatusSetting[] GetAllStatuses(String installation){
StatusSetting[] statuses = null;
String methodName = "GetAllStatuses";
String soapAction = NAMESPACE + "/" + methodName;
SoapObject request = new SoapObject(NAMESPACE, methodName);
request.addProperty("installation", installation);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
AndroidHttpTransport httpTransport = new AndroidHttpTransport(SERVICE_URL);
try {
httpTransport.call(soapAction, soapEnvelope);
statuses = (StatusSetting[])soapEnvelope.getResponse();
} catch (Exception e) {
e.printStackTrace();
}
return statuses;
}