我已成功通过xmlrpc api将我的Android应用程序连接到magento服务器。我也使用xmlrpc api成功检索了'catalogcategory.tree'。现在我想从他们的'产品ID'中检索产品图像,因此以下是我在android中编写的代码
Map map = new HashMap();
map.put("product_id", 12446);
map.put("product_id", 12445);
Object[] productdetails1=new Object [] {map};
Object medialist = null;
Object param1[]=new Object[]{productdetails1};
Object param[]=new Object[]{CS_CONSTANTS.session_id,"catalog_product_attribute_media.list",param1};
try {
medialist=client.callEx("call", param);
Log.i("Out Put of Adding", medialist.toString());
} catch (Exception e) {
e.printStackTrace();
}
Log.e("HERE","is array : " + String.valueOf(medialist.getClass().isArray())+"\n"
+"class : " + medialist.getClass().toString()+"\n"
+"hashCode : " + String.valueOf(medialist.hashCode()));
以下是例外
//12-27 15:11:04.936: W/System.err(22977): com.cs.xmlrpc.libraries.XMLRPCFault: XMLRPC Fault: Product not exists. [code 101]
//12-27 15:11:04.936: W/System.err(22977): at com.cs.xmlrpc.libraries.XMLRPCClient.callEx(XMLRPCClient.java:226)
以下是在服务器
上运行正常的相应SOAPV1代码$client = new SoapClient('http://magentohost/api/soap/?wsdl');
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'catalog_product_attribute_media.list', '12446');
var_dump($result);
我已经交叉检查了输入的产品ID,它们都是有效的并存在于我的magento服务器上
答案 0 :(得分:0)
试试这个......它对我有用:
String product_id="325";
Object[] array= (Object[]) client.callEx("call",new Object[] session_id,"product_media.list",new Object[]{product_id}});
for (Object s:array) {
hashMap1=(HashMap)s;
Log.i("ImageURL:",hashMap1.get("url").toString());
//[types, exclude, position, url, label, file]
}