我需要将一个字符串数组传递给一个预定义的webserivce,用于接受一个字符串值数组。但是,当我创建一个soap信封并将 array.class 或 string.class 属性设置为请求时,它会抛出序列化错误。
对上述内容有何建议?应该建议的数据类型或方法可以解决相同的问题。
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
PropertyInfo p1 = new PropertyInfo();
p1.setName("items");
p1.setValue(results);
p1.setType(String.class); // else Array.class.
request.addProperty(p1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
httpTransport.debug = true;
httpTransport.call(SOAP_ACTION, envelope);
// throws an error in the above.
result = httpTransport.responseDump;
答案 0 :(得分:2)
答案 1 :(得分:0)
只需在循环中传递参数名称和值:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL);
for (int i=0; i<itemId.length; i++){
request.addProperty("itemID",itemId[i]);
}
ht.call(SOAP_ACTION, envelope);
使用request.addProperty
在循环中传递parametername和item值