我正在尝试将关联数组从 Java 传递给 PHP。我收到“无法序列化异常”。
后端 php 代码(soap 调用)是这样的:
function getTrips($data)
{
foreach($data as $key => $value)
{
...
}
}
我正在像这样进行java客户端调用:
HashMap<String, String> Data = new HashMap<String, String>();
Data.put("start_date", dateFormat.format(date));
Data.put("end_date", dateFormat.format(date));
Data.put("loc", "1");
request.addProperty("data",Data );
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
我尝试使用 NameValuePair 代码是这样的:
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(6);
nameValuePairs.add(new BasicNameValuePair("start_date", dateFormat.format(date)));
nameValuePairs.add(new BasicNameValuePair("end_date", dateFormat.format(date)));
request.addProperty("data",nameValuePairs );