我正在使用 Android ksoap2 库来使用 SOAP Web 服务。
请求中的一个节点看起来像..
//some more nodes
.............
<dateVals i:type="n0:dateTimeArray">
<item i:type="d:dateTime">1988-09-17</item>
</dateVals>
..........
//some more nodes
这就是我正在尝试的方式
SoapObject request = new SoapObject(Commons.NAMESPACE,
Commons.METHOD_NAME_REGISTER);
SoapObject dateParent = new SoapObject("", "dateVals");
PropertyInfo dobItem = new PropertyInfo();
dobItem.setName("item");
dobItem.setValue("1988-09-09");
dobItem.setType("d:dateTime");
dateParent.addProperty(dobItem);
request.addProperty("dateVals", dateParent);
服务器抛出错误,因为它不是预期的格式。
我在哪里做错了?
编辑
完整的请求,这里HashMap<String, String> values;
来自其他类。
SoapObject request = new SoapObject(Commons.NAMESPACE,
Commons.METHOD_NAME_REGISTER);
request.addProperty("authUser", Commons.AUTH_USER);
request.addProperty("authKey", Commons.AUTH_KEY);
request.addProperty("storeName", Commons.STORE_NAME);
request.addProperty("sms", "true");
request.addProperty("firstName", values.get("firstName"));
request.addProperty("lastName", values.get("lastName"));
request.addProperty("sex", values.get("sex"));
request.addProperty("language", values.get("language"));
request.addProperty("email", values.get("email"));
SoapObject dateParent = new SoapObject("", "dateVals");
PropertyInfo dobItem = new PropertyInfo();
dobItem.setName("item");
dobItem.setValue(values.get("dateVals"));
dobItem.setType("d:dateTime");
dateParent.addProperty(dobItem);
request.addProperty("dateVals", dateParent);
request.addProperty("phoneNumber", values.get("phoneNumber"));
request.addProperty("password", values.get("password"));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransportSE = new HttpTransportSE(
Commons.URL_NEW_MEMBER);
httpTransportSE.debug = true;
try {
Commons.lastTouchTime = System.currentTimeMillis();
httpTransportSE.call(
Commons.NAMESPACE.concat(Commons.METHOD_NAME_REGISTER),
envelope);
SoapObject response = (SoapObject) envelope.bodyIn;
responseCode = Integer.parseInt(response.getProperty("return")
.toString());
} catch (Exception e) {
responseCode = -1;
e.printStackTrace();
}