Recently I've had a task to write small integration of Java to the Magento API, and meet a lot of troubles on the way. First of all Magento supports SOAP web-services that actually don't work well, I've found one solution
http://code.google.com/p/magja
I didn't tried because we spend much time trying to make them work with no result, so next was XML RPC based API that worked quite well on PHP examples, but caused more trubles.
Login worked pretty well:
But other call's did worked, instead they show:
By tracing PHP side I've figured out that this is a problem of array's "matreshka"(arrays in arrays) and this how it works fine:
Now it worked fine, but there was parsing problem
http://libjack.com/2009/03/26/java-magento-xmlrpc-api-nil-issue/
Problem that PHP return unknow type is handled by custom TypeFactory, check the article.
So now it works fine, hope it will help for everybody else, because I've found a lot of unsolved questions on Magento forum.
http://code.google.com/p/magja
I didn't tried because we spend much time trying to make them work with no result, so next was XML RPC based API that worked quite well on PHP examples, but caused more trubles.
Login worked pretty well:
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http://magento.dev/index.php/api/xmlrpc/")); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); Vector params = new Vector(); params.addElement( "defsan" ); params.addElement("123456"); String session = (String)client.execute( "login", params );
But other call's did worked, instead they show:
Exception in thread “main” org.apache.xmlrpc.XmlRpcException: Calling parameters do not match signature
By tracing PHP side I've figured out that this is a problem of array's "matreshka"(arrays in arrays) and this how it works fine:
Object[] methodParams = new Object[]{"123" }; Object[] callParams = new Object[]{session,"customer.info", methodParams}; Object user = client.execute( "call", callParams ); System.out.println(user.toString());
Now it worked fine, but there was parsing problem
org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse server's response: Unknown type: nilI've found solution online:
http://libjack.com/2009/03/26/java-magento-xmlrpc-api-nil-issue/
Problem that PHP return unknow type is handled by custom TypeFactory, check the article.
So now it works fine, hope it will help for everybody else, because I've found a lot of unsolved questions on Magento forum.
Comments
Outsource magento ecommerce services india | Outsource ecommerce development services