Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Nil type problem with xmlrpc and java
 
radoslawg
Jr. Member
 
Total Posts:  14
Joined:  2008-12-30
 

Hi,
I’m writing xmlrpc client with java and I stumbled upon another problem.

I receive error:

org.apache.xmlrpc.client.XmlRpcClientExceptionFailed to parse server's response: Unknown type: nil
    at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:180)
    at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:148)
...
Caused by: org.xml.sax.SAXParseException: Unknown type: nil
    at org.apache.xmlrpc.parser.RecursiveTypeParserImpl.startElement(RecursiveTypeParserImpl.java:118)
    at org.apache.xmlrpc.parser.MapParser.startElement(MapParser.java:155)
...
Caused by:
org.xml.sax.SAXParseException: Unknown type: nil
    at org.apache.xmlrpc.parser.RecursiveTypeParserImpl.startElement(RecursiveTypeParserImpl.java:118)
    at org.apache.xmlrpc.parser.MapParser.startElement(MapParser.java:155)
...

I’m trying to run method “product.info” with params:

XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        
config.setServerURL(new URL(SHOP_XMLRPC));
        
config.setEnabledForExtensions(true);
        
config.setEnabledForExceptions(true);

        
XmlRpcClient client = new XmlRpcClient();
        
client.setConfig(config);

        
Object[] params = new Object[]{(productId).toString()};

            
Object[] inParams null;
            if (
params == null{
                inParams 
= new Object[]{sessionIdmethodName};
            
else {
                    inParams 
= new Object[]{sessionIdmethodNameparams};
            
}

            result 
client.execute("call"inParams);

Magento 1.2.1, Java 1.6, xmlrpc library from apache.

I’m using similar code to fetch product list and product stock. It works there so I’m guessing there is some “null” in this response that java’s library cannot cope with.
Any help?

Thanks,
Radek.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dhoover
Jr. Member
 
Total Posts:  27
Joined:  2009-02-23
 

I am also writing a java xmlrpc client. How do you “login” to get the sessionid?

Thanks.
Dean

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pauluz
Jr. Member
 
Total Posts:  3
Joined:  2009-01-02
 

You need to do this to login

result = client.execute("login", new Object[]{username,password});

result will then contain the sessionid.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dhoover
Jr. Member
 
Total Posts:  27
Joined:  2009-02-23
 

Thanks. Now I can get the category tree and the product list, with no arguments. Still playing around with argument passing, which is a bit confusing. For example, How would I set up a call to “product.info”. Can’t seem to get it to work.

Thanks.
Dean

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pauluz
Jr. Member
 
Total Posts:  3
Joined:  2009-01-02
 

I haven’t done this myself but looking at PHP examples: i’ll guess you will need a Hashmap with key -> value pairs, where key is the argumentname and value the value?
So the object structure you need to send will probably look like “new Object[]{sessionId, methodName, hashmap}”
Give it a try smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
dhoover
Jr. Member
 
Total Posts:  27
Joined:  2009-02-23
 

Nope. I’ve tried all sorts of variations including what radoslawg did to start this topic (although I think the product_id should be passed as an Integer in order to differentiate it from a sku, which would be a String. And, if the arguments would be packaged in a Map, I did not see that in the php, and I would not know what the key was supposed to be anyway.

For the product.info call, I see a SOAP PHP example that looks like this:

var_dump($proxy->call($sessionId, ‘product.info’, ‘sku_of_product’));

This is what I do in java xmlrpc:

int product_id = 166;
Object[] params = {session_id, “product.info”, product_id};
Object[] result = (Object[])client.execute("call", params);

When I run it I get the following exception:
Exception in thread “main” org.apache.xmlrpc.XmlRpcException: Calling parameters do not match signature

On a related note, I noticed that all real examples I have seen have been in PHP SOAP so I am wondering if the problem is:
a) there is something weird about the XMLRPC between java and PHP
b) the magento XMLRPC interface does not completely work. I did get it to work for calls that take no arguments: product.list and category.tree

Has anyone had any luck using XMLRPC calls in either PHP or java?

Thanks.
Dean

 
Magento Community Magento Community
Magento Community
Magento Community
 
libjack
Jr. Member
 
Total Posts:  3
Joined:  2009-02-23
 

posted a solution to this on a similar thread ... basically the Magento server is using nil when it shouldn’t ... if using the apache ws-xmlrpc library, a simple work around is possible.

 
Magento Community Magento Community
Magento Community
Magento Community
 
panticz.de
Jr. Member
 
Total Posts:  19
Joined:  2009-01-16
Germany
 

Hello everybody!

I am currently writing a Magento Connector for Java. The goal is to create a free wrapper / library to manage Magento from a Java application. A few parts such as management of products, categories and pictures are already partially finished and can be used.

The latest version (source code and JAR package) can be downloaded from this homepage:
http://www.panticz.de/MagentoConnector/

If someone is interested in co-development, please contact my here.

Greeting

Pawel

 
Magento Community Magento Community
Magento Community
Magento Community
 
ceefour
Member
 
Avatar
Total Posts:  52
Joined:  2008-09-16
Bandung, Indonesia
 
libjack - 27 March 2009 05:08 AM

posted a solution to this on a similar thread ... basically the Magento server is using nil when it shouldn’t ... if using the apache ws-xmlrpc library, a simple work around is possible.

Thanks libjack! You rock!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top