我尝试了许多不同的方式来调用“使用cart_paymant.method
”API
但总是失败。 Magento
XMLRPC
下面是我用来调用它的代码。
Map<String,String> map = new HashMap<String,String>();
map.put("method","checkmo");
//map.put("po_number",null);
//map.put("cc_cid", null);
//map.put("cc_owner",null);
//map.put("cc_number",null);
//map.put("cc_type",null);
//map.put("cc_exp_year",null);
//map.put("cc_exp_month",null);
Object[] paymentMethod=new Object [] {map};
Object param1[]=new Object[]{shoppingCartId,paymentMethod};
Object param2[]=new Object[]{Utils.sessionId,"cart_payment.method",param1};
try
{
Boolean ans=(Boolean)client.callEx("call", param2);
Log.i("Payment Method Setting : ", ""+ans);
}
catch (XMLRPCException e) {
e.printStackTrace();
return 0;
}
我得到的例外:
java.io.IOException: Cannot serialize null
at org.cws.magentoAnd.xmlrpc.XMLRPCSerializer.serialize(XMLRPCSerializer.java:99)
at org.cws.magentoAnd.xmlrpc.XMLRPCSerializer.serialize(XMLRPCSerializer.java:89)
at org.cws.magentoAnd.xmlrpc.XMLRPCSerializer.serialize(XMLRPCSerializer.java:72)
at org.cws.magentoAnd.xmlrpc.XMLRPCSerializer.serialize(XMLRPCSerializer.java:72)
at org.cws.magentoAnd.xmlrpc.XMLRPCCommon.serializeParams(XMLRPCCommon.java:36)
at org.cws.magentoAnd.xmlrpc.XMLRPCClient.methodCall(XMLRPCClient.java:253)
at org.cws.magentoAnd.xmlrpc.XMLRPCClient.callEx(XMLRPCClient.java:174)
仅供参考,我还发布了 Web 上提供的调用该 API 的 php 代码。
$paymentMethod = array(
“method” => “checkmo”
);
$resultPaymentMethod = $proxy->call(
$sessionId,
“cart_payment.method”,
array(
$shoppingCartId,
$paymentMethod
)
);