The first time I tried to write a web service in Java (armed with a brand-new manual a foot thick), it took me two weeks to make it work.

Sunday
2 Apr 2006

Java vs. Python: XML-RPC

Software Development

I am a happy programmer right now. Working at Humanized is fun for many reasons, but one thing that makes us programmers especially happy is having tools that do what we want instead of getting in our way. Over the past few months we’ve painstakingly set up an excellent development environment for ourselves, and now I think it’s really paying off. Since one of my titles is “toolsmith”, I’ll probably write quite a bit about development tools for this blog.

Before coming to Humanized, I worked at Argonne National Laboratory as a research assistant on “The Grid”. We did a lot of web-services development, and we had to use Java. The first time I tried to write a web service in Java (armed with a brand-new manual a foot thick), it took me like two weeks to make it work. I had to install Apache Jakarta Tomcat and then install Axis inside of Tomcat and then write WSDL and WSDD and learn SOAP and define data-type mappings and Java interfaces and generate stub code and link in .jars and write Ant tasks in XML to control build and deployment processes and grovel through cryptic stack traces trying to figure out what was going wrong and write posts to mailing lists asking for help because following the Apache Axis documentation wasn’t working. This was to write the most trivial, “Hello, World” level of web service, just a function to add two numbers together.

Yesterday, I tried to set up an XML-RPC server in Python. I need it for the automated test-farm (or “Test Pharm”) I’m working on. No need to install anything — the xmlrpc module is part of the Python standard library. You can write an XML-RPC server in less than eight lines of Python. You just define the function you want to make available, pass it to the the SimpleXMLRPCServer class, and give the server a port to start running on. The client is six lines, including error handling. You run the server, you run the client, they talk to each other. I looked up “Python XML-RPC” yesterday morning, knowing nothing about it, and I had a fully functional XML-RPC system for my Test Pharm about half an hour later.

I wanted to cry.

In summary: choosing Python as our primary development language was the best decision we ever made.

by Jono DiCarlo



COMMENTS

9 Voices Add yours below.


Salvatore Insalaco
April 12th, 2006 7:26 am

I’m a great fan of Python too, and I work daily with Java.
I pretty much agree with your feelings, but you have to be fair: XML-RPC is REALLY more simple than SOAP.
There’re some really good XML-RPC libraries for Java “nearly” as simple to use than the Python ones, and the SOAP support of various Python libraries ranges from terrible to awful (at least it was one and half years ago, when I worked on it).
So, you’re right about Python, but you have to compare apples to apples :).


Salvatore Insalaco
April 12th, 2006 7:33 am

For the sake of comparison, this is an XML-RPC client made using Apache XML-RPC library in Java:

    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    config.setServerUrl("http://127.0.0.1:8080/xmlrpc");
    XmlRpcClient client = new XmlRpcClient();
    client.setConfig(config);
    Object[] params = new Object[]{new Integer(33), new Integer(9)};
    Integer result = (Integer) client.execute("Calculator.add", params);

6 lines too, without error handling, but not really difficult ;).
I love Python too, this is just my “devil’s lawyer” work :).


Heh, that’s true. I guess along those lines, though, it’d be nice if there was a robust RPC interface that followed the principle of simple things should stay simple: a library that makes really basic web services as easy as using XML-RPC, but still has support for more complex operations like asynchronous method calls if they’re needed.


Speaking of this, Bruce Eckel recently wrote an interesting post on using Twisted Python to do asynchronous method calls using an interface that’s less cumbersome than SOAP.


Mikeal Rogers
June 14th, 2006 8:27 pm

I’m coming upon this article a bit late, but I couldn’t help but comment.

I’m currently working on a distributed testing system, which sounds like it may have a little in common with pharm in that it requires some distributed computing.

If you thought easily installed the SOAP module was cool this’ll make you flip.

http://pyro.sourceforge.net/

Basically it sends python objects over the network using pickle, which means it can send nearly any python object you can define except socket and file objects.


Did you write up your experience taking two weeks to do something hard in Java?

Would having that write-up save one a lot of time and agravation?

Are you sharing it within the company or outside it?

I’d like to see some exemplar programs in Java and Python, with commentary, on a wiki, for me and others to learn from AND improve in quality over time.


Richard Karpinski
September 23rd, 2006 4:06 pm

I followed a link to

Simple things should stay simple

Then I tried to follow the first link there but I got a bare 404. Wouldn’t it be better if the system left you editing a feedback report which had the 404 and the offending link already embedded in the message?

But I had to come back here to tell anyone since you don’t have a feedback link that I can find on each page. How do you expect to hear about page specific problems>


Woah…old post but still…

Anyway, I came across this post looking Python and XML-RPC.

Anyone here know just how robust the standard XML-RPC server is in Python? On average hardware, do you think it could handle thousands of requests per hour? Minute?

I’m looking for a way to queue up image resize jobs.

Thanks
cbmeeks
http://www.signaldev.com


Critics are left largely unimpressed at the opening night of the Lord of the Rings musical on the London stage…


POST A COMMENT

Please respect this public space


 Required

 Required



 

Live comment preview