ksoap2铸造的GetResponse() [英] ksoap2 casting getResponse()
问题描述
从调用Android的使用ksoap2 LIB一个.NET SOAP1.1 Web服务我遇到铸造响应自定义对象的问题。比如code以下之后httpTransport.call(的soapAction,的SoapEnvelope)呼吁正确的;并且里面有数据。但我cant't它转换为特定的对象既不是SoapObject或Vector我在几个例子中所看到的,我得到CastException或简单的什么都没有。 如果有人知道如何对付它,请帮助。
公共StatusSetting [] GetAllStatuses(字符串安装){
StatusSetting []状态= NULL;
字符串方法名=GetAllStatuses;
字符串的soapAction = NAMESPACE +/+方法名;
SoapObject请求=新SoapObject空间(namespace,方法名);
request.addProperty(安装,安装);
SoapSerializationEnvelope的SoapEnvelope =新SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = TRUE;
soapEnvelope.setOutputSoapObject(要求);
AndroidHttpTransport httpTransport =新AndroidHttpTransport(SERVICE_URL);
尝试 {
httpTransport.call(的soapAction,的SoapEnvelope);
状态=(StatusSetting [])soapEnvelope.getResponse();
}赶上(例外五){
e.printStackTrace();
}
返回状态;
}
第一次尝试,看看你得到任何回应。
obj对象= envelope.bodyIn;
如果这个 OBJ
不为空,然后尝试以下。
SoapObject resultsRequestSOAP =(SoapObject)envelope.bodyIn;
我的猜测是,这应该工作,如果你得到了一些响应。
您需要告诉KSOAP什么 StatusSetting
对象和如何
来SOAP响应转换成一个 StatusSetting
对象。
Calling a .net SOAP1.1 web service from android using ksoap2 lib I met a problem of casting response to a custom object. For instance the code below is called correct after httpTransport.call(soapAction, soapEnvelope); and have data inside. But I cant't cast it to specific object neither to SoapObject or Vector as I saw in several examples, I get CastException or simple nothing. If somebody knows how to deal with it, please help.
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;
}
First try and see if you are getting any response.
Object obj = envelope.bodyIn;
if this obj
is not null then try the following.
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
My guess is this should work if you are getting some response.
You need to tell kSOAP what StatusSetting
object is and how
to convert a SOAP response to to a StatusSetting
object.
这篇关于ksoap2铸造的GetResponse()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!