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