I am trying to call a web service from Android client on the Magento Store.
I have good success till now but have little problem.
I want this array to be converted in to appropriate java Object.
$arrProducts = array(
array(
"product_id" => "1",
"qty" => 2
),
array(
"sku" => "testSKU",
"quantity" => 4
)
);
$resultCartProductAdd = $proxy->call($sessionId, "cart_product.add",
array($shoppingCartId, $arrProducts));
The Above php code has been taken from here
What I have tried.
Object []addtocart=null;
Log.i("Product Id ", Utils.product_list.get(rowid).getp_Id());
Object[] productdetails1=new Object[]{Utils.product_list.get(rowid).getp_Id(),2};
//Object[] productdetails2=new Object[]{productdetails1};
Object param1[]=new Object[]{Utils.shoppingCartId,productdetails1};
Object param[]=new Object[]{Utils.sessionId,"cart_product.add",param1};
try {
addtocart=(Object[])client.callEx("call", param);
} catch (XMLRPCException e) {
e.printStackTrace();
}
But it results into error like the :
org.cws.magentoAnd.xmlrpc.XMLRPCFault: XMLRPC Fault: One item of products do not have identifier or sku [code 1022]
at org.cws.magentoAnd.xmlrpc.XMLRPCClient.callEx(XMLRPCClient.java:228)
at org.cws.magentoAnd.ProductModule.productdetails$CartFunctions.doInBackground(productdetails.java:245)
at org.cws.magentoAnd.ProductModule.productdetails$CartFunctions.doInBackground(productdetails.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)
I would be happy if someone having dual knowledge of php and Java would help me to solve this Issue.
Ok,getting some Ideas from
@ sharadendu sinha'sAnswer, I have made aAssociative Arraylike thing in Java that would get the required result.The code is as below.