1
我正在使用ksoap2與遠程Web服務進行通信。出於某種原因,我添加到soapObject的屬性不會被髮送。我哪裏錯了?我嘗試了一切,當我執行請求xml的直接發佈時,我得到了一個響應,但這不是我想要的。我也得到了服務器的響應,但是我發佈的任何值都沒有被傳遞。我已經閱讀過每個博客,官方文檔甚至相關的SO問題,我錯過了什麼?Android ksoap2,數據未被髮布
這是從異步任務的doInBackground()調用的方法的一個片段。
public SoapObject getSoapObject() {
// Create request
SoapObject requesty = new SoapObject(NAMESPACE, METHOD_NAME);
// Add the property to request object
requesty.addProperty(getPropertyInfo("PARAMETER_1", "VALUE_1"));
// Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
// Set output SOAP object
envelope.setOutputSoapObject(requesty);
// Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
SoapObject soapObject = null;
try {
// Send to web service
androidHttpTransport.call(SOAP_ACTION, envelope);
soapObject = (SoapObject) envelope.getResponse();
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (HttpResponseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return soapObject;
}
private PropertyInfo getPropertyInfo(String name, String value) {
PropertyInfo propInfo = new PropertyInfo();
propInfo.setName(name);
propInfo.setValue(value);
propInfo.setType(string.class);
return propInfo;
}