0
我已经搜索了很多,但没有找到任何帮助,所以希望有人能够对此事发表一些看法。Android KSoap2来自服务器阵列的响应是空的
我想用KSOAP发送一个数组,我这样做如下:
首先我构造SOAP对象是这样的:
SoapObject request = new SoapObject(GENERICNAMESPACE, SOAP_METHOD_NAME);
PropertyInfo attr = new PropertyInfo();
attr.name = "patientLogin";
attr.type = PropertyInfo.STRING_CLASS;
attr.namespace = GENERICNAMESPACE;
attr.setValue(patientId);
request.addProperty(attr);
//could be patientPassword
attr = new PropertyInfo();
attr.name = "passwd";
attr.type = PropertyInfo.STRING_CLASS;
attr.namespace = GENERICNAMESPACE;
attr.setValue(patientPassword);
request.addProperty(attr);
Vector vectorOfIDsRead = new Vector();
vectorOfIDsRead.addElement(idsRead);
attr = new PropertyInfo();
attr.name = "IDsRead";
attr.type = PropertyInfo.STRING_CLASS;
attr.namespace = GENERICNAMESPACE;
attr.setValue(vectorOfIDsRead);
request.addProperty(attr);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER10);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(GENERICURL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(GENERICSOAP_ACTION_URL+"feedbackRead", envelope);
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope
.getResponse();
//log request
Log.e("SendFeedbackRead", "/////////////////////RequestDump////////////////////");
Log.e("SendFeedbackRead", androidHttpTransport.requestDump.toString());
Log.e("SendFeedbackRead", "/////////////////////////////////////////");
//log request
Log.e("SendFeedbackRead", "///////////////////ResponseDump/////////////////");
Log.e("SendFeedbackRead", androidHttpTransport.responseDump.toString());
Log.e("SendFeedbackRead", "/////////////////////////////////////////");
Log.e("FeedbackRead",
"FeedbackRead : " + resultsRequestSOAP.toString());
return resultsRequestSOAP.toString();
} catch (Exception e) {
Log.e("FeedbackRead", "SENDFEEDBACKREAD : " + e);
return e.getMessage();
}
请求转储表明我送:
<v:Envelope xmlns:i="http://www.w3.org/1999/XMLSchema-instance" xmlns:d="http://www.w3.org/1999/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header />
<v:Body>
<n0:feedbackRead id="o0" c:root="1" xmlns:n0="http://testing.starburst.com/GenericWS">
<n0:patientLogin i:type="d:string">patient1</n0:patientLogin>
<n0:passwd i:type="d:string">pat1</n0:passwd>
<n0:IDsRead i:type="c:Array" c:arrayType="d:anyType[1]"><item i:type="d:string">1234test</item></n0:IDsRead></n0:feedbackRead>
</v:Body>
</v:Envelope>
但我得到的回应声明列表为空。
feedbackRead,空提交的ID列表!
它不是因为它有一个价值。
任何人都可以指向正确的方向吗?
谢谢。
感谢您的意见。我试图改变你在代码中所做的差异,但是这并没有帮助,于是我跟着教程。再次,没有结果。方法名称是SOAP_METHOD_NAME =“feedbackRead”。 – 2012-04-04 10:02:23
为什么会发生此错误?对我来说很明显,矢量不是空的。服务器没有看到的原因是什么?响应已更改,以显示id列表与服务器的一样:04-03 19:22:17.082:E/SendFeedbackRead(18129): feedbackRead,空提交的ID列表! 它有这些值 这不是id列表。我认为我的问题的答案就在那里。 –
2012-04-04 10:03:14
通过方法签名我的意思是“feedbackRead”方法的参数的数量和类型。 (对不起我的英语不好)。我不知道其他方式来传递数组。 – 2012-04-04 10:18:40