我正在使用ksoap2与远程Web服务进行通信。由于某种原因,我没有发送添加到soapObject的属性。我哪里弄错了?我已经尝试了所有的东西,当我执行请求xml的直接发布时,我收到了回复,但这不是我想要的。我也从服务器得到响应,但我发布的值都没有传递。我已经阅读了每一篇博客,官方文档,甚至是相关的SO问题,我错过了什么?
以下是从异步任务的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;
}
答案 0 :(得分:0)
我没有使用ksoap2,而是通过HttpPost直接发布,并使用自定义XML解析器手动解析不同的值。我知道这可能不是最好的选择,但SOAP现在只是老派。