2

I am making a request to the Magento Server using XMLRPC to get the details using multiCall() function.
I have achieved success in calling the multiCall() function as it does not results to any Exception.

I am using Objects to send data and when I use Object DataType to get the response,It gives the Exception like

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:200)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
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)
Caused by: java.lang.ClassCastException: [Ljava.lang.Object;
at org.xmlrpc.ProductService$doingBackTask.doInBackground(ProductService.java:94)
at org.xmlrpc.ProductService$doingBackTask.doInBackground(ProductService.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)    

The code that I use to call is as followed:

Object[] skuid=new Object[product_list.size()];
Object calling[]=new Object[product_list.size()];

for(int m=0;m<product_list.size();m++)
{
    skuid[m]=new Object[]{product_list.get(m).getp_Sku()};
    calling[m]=new Object[]{"catalog_product_attribute_media.list",skuid[m]};   
}

Object b[][];
try 
{
  // The Upcoming line causes Exception : java.lang.ClassCastException 
  b=(Object[][])client.callEx("multiCall",new Object[]{sessionId,calling});  
}
catch (XMLRPCException e) 
{
    e.printStackTrace();
}
Haresh Chaudhary
  • 4,390
  • 1
  • 34
  • 57

1 Answers1

0

The exception is pretty much self-explanatory: the result of the callEx method call is of type java.lang.Object and you're trying to cast it to String[][].

Obviously, the returned value is not of type String[][]. Do you have the source of this callEx method? If yes, I suggest that you dig into it to see what exactly it returns.

Aleks G
  • 56,435
  • 29
  • 168
  • 265
  • Aleks G...Me Hard luck..Actually I have edited it and made it to Object,just at the time you might be Answering to it.We both might be in the Edit Mode.Actually I was trying many different things before Putting the Question Here.And and it was the last thing here that I have tried..:))..Actually multiCall() is a API call that Magento provides.I don't have the Code.The call I have made will return list of URLS of the images of the products.But replacing it with the Object also Gives me the same Exception. – Haresh Chaudhary Aug 29 '12 at 11:11
  • @HareshChaudhary Please show the code of `callEx` method - this is the one responsible for packaging the result. – Aleks G Aug 29 '12 at 11:13
  • Aleks G : It's an inbulit method provided by Android-XMLRPC library...but still I would like to give the like of the class you ask me..It's here..http://pastie.org/private/uidmu3pwrnhkmpc1tneq – Haresh Chaudhary Aug 29 '12 at 11:23
  • @HareshChaudhary What is `iXMLRPCSerializer` in line `Object obj = iXMLRPCSerializer.deserialize(pullParser);`? What class is this object of? Is it your own class? – Aleks G Aug 29 '12 at 12:25
  • Aleks G : No,Actually that serialization and de-serialization is done by the Library...It's a class of the Library..If you want to view that class then please let me know..I will post it and give you a link for that...There is no problem with that I hope so because before calling this multiCall() function I have called many more methods..like login,call etc. – Haresh Chaudhary Aug 29 '12 at 12:35
  • Aleks G : That Line you described De-Serializes the response that is received from the Server on the Client side using that Library class. – Haresh Chaudhary Aug 29 '12 at 12:36
  • 1
    @HareshChaudhary Yes, I understand that; it's specifically this line that produces the result different from the one you want. – Aleks G Aug 29 '12 at 14:26
  • Yes.But then I can't do any tampering with that class,as other calls that I make get De-serialize with an ease using that class. And tampering it would make their a problem. – Haresh Chaudhary Aug 30 '12 at 04:32