Tag Archives: xmlrpc

Magento api with Java Client — problem with XML-RPC interface

One of the features touted by Magento is the api exposed via both XML-RPC and SOAP. I quickly (and successfully) tested the SOAP interface using the amazingly complete (and free) soapUI. I wanted to use XML-RPC, and decided to build a test client in Java. While trying to build a client, using the apache ws-xmlrpc library, I ran into a roadblock. The initial login and some other calls would work just fine, but some calls such as product.info would always cause an exception, similar to:

Exception in thread "main" org.apache.xmlrpc.client.XmlRpcClientException:
Failed to parse servers response: Unknown type: nil

I posted on the magento forum to no success (except to find a few others with the same problem). So I was on my own..

After some research, I determined that the problem (IMHO) is that the Magento api is incorrectly using the nil type in responses. According to the XML-RPC spec, nil is an extended type, and can only be used with a namespace (e.g. ex:nil) — see the data types section on the apache site. But, luckily, the ws-xmlrpc library can be easily extended to provide a work around, and the following solution worked for me.

Continue reading