Monday, February 06, 2006

SOAP Protocol

Back in 2004, for my end of year university project, I decided to find ways to optimize the SOAP protocol, used for the invocation of web services, and to build an implementation of this protocol with the selected optimizations. During my literature survey I found a lot of research papers focusing on different performance problems of the protocol and proposing solutions.

Using a mix of these different solutions, I built my implementation of a SOAP RPC client and server which I’m posting here:

Binary, source & docs: http://www.vikash-madhow.com/files/soap/SOAP_RPC_0.8_ALL.zip

This server was tested against Apache Axis and had lower response times on almost all tests. The performance results are included in the full documentation found in the /doc folder.

For the sake of simplifying the server to a level that it can easily be grasped and re-used – if needed - by most, I’ve removed anything that I considered not part of the gist of the implementation. This included all the axis performance and interoperability tests, a simple SOAP client and server over the TCP protocol transport used during early tests and an implementation of the SOAP RPC server using the open-source jetty web server. If you want the original implementation, please email and I’ll send it to you.

The implementation contains the following optimizations amongst others:

  1. Uses an XML pull-parser for parsing SOAP messages (instead of a DOM or SAX parser).
  2. SOAP messages are encoded in the literal format instead of the SOAP encoding format.
  3. Uses the HTTP chunked transfer encoding for the transmission of SOAP messages which transmits messages in packets known as chunks.
  4. Compression of SOAP messages.
  5. Uses HTTP persistent connections and request pipelining.
Another interesting feature of this implementation is the HTTP layer which has been built as a set of I/O stream filters. Working thus with the HTTP layer is no more complicated than reading and writing files from the filesystem. The layer is also symmetric in the sense that using it on the server side is almost exactly the same as using it on the client side. To make things even simpler, there is a Connection abstraction that hides every details of the underlying network protocol.

Enjoy and let me know about any problems that you may encounter. If you reuse part or whole
I only ask for proper acknowledgement of source.

PS: The documentation is in the OpenDocument format and you can download OpenOffice 2 to read it from here: http://www.openoffice.org/

Friday, February 03, 2006

Pacman

Some weeks back, I delivered a Java training for the company I work for. From the start, I wanted the training to end with each participant having actually written a complete Java application of some reasonable complexity.

We decided on writing a version of the famous Pacman game. Actually, as the tutor I had more of a say on this decision and I felt at that time that Pacman was neither too simple nor too complex a program to write. In retrospect, this was not the best of my decisions. Pacman turned out to more complex to implement (if you want to do it properly) than I initially thought.

In the end, nobody succeeded in the assignment but everybody learnt a couple of things (top of the list must be that programming is harder that it looks). It took me 7 days to write my version of Pacman which I've uploaded here:

Binary: http://www.vikash-madhow.com/files/pacman-1.0.jar
Source: http://www.vikash-madhow.com/files/sources-1.0.zip

If Java (version 5.0) is installed properly on your computer, you only need to double-click on the binary file to run it. Finding your way after this is pretty simple.

The more interesting part, however, is the source code. It has been written to demonstrate all the good Java programming practices that I was trying to deliver to the audience - with compromises where the purist's approach would have taken too long. Unlike many Pacman implementations I've seen on the web, this once actually consists of more than one class. It has about 30, in fact. All of them are reasonably small and have well-defined purposes. Someone can very easily create new characters, mazes, etc. simply by extending the proper class.

Another interesting feature in this implementation of Pacman is that the mazes are built randomly every time you start a new game, so that you never come across the same maze twice. It also has an implementation of the A* Search algorithm used by the Ghosts to calculate shortest distance in the maze to Pacman when attacking and shortest distance to their lair when fleeing.

Enjoy.

PS: I would love to hear suggestions but due to time constraints I may not be able to change the program. But please feel free to use and modify the code to suit your purposes. All I ask is that you acknowledge your source.