I'm doing an experiment, developing an enterprise application in Java and Ruby in parallel, trying to evaluate whether Ruby is enterprise ready, or Java must still remain my weapon of choice.

Thursday, November 30, 2006

First Rails Drawback

It had to come at some point, I just didn’t expect it so fast.
I regret to report that I came across my first hurdle with Rails today.
The idea was to quickly finish prototyping my web services (see previous post), so that I could give the client application team a WSDL they can already work with. However, when I took a good look at the WSDL file, I realized that it’s RPC/encoded, rather than the standard today – Document/literal.
That’s bad practice: first of all, this style isn’t WS-I compliant, and second, performance tends to degrade much faster.
I started looking for the way to configure AWS to work doc/lit style, and soon found out that there isn’t one – it’s just not supported at the moment.
Now, since I intend to use doc/lit with my Java system, this issue violates my success criterion #1 – my Rails and Java applications won’t be interchangeable; I can’t do with Rails anything that I can do with Java.
Worse, I’m going to have to integrate with some 3rd party products, and the plan was to do that via their SOAP API. Since they probably use doc/lit, that being the enterprise standard (WS-I compatibility and all), it’s likely that I won’t have a fast way to do that with Ruby.

I realize that for the broad Ruby and Rails community this isn’t much of an issue; most web apps are better off using REST rather than SOAP, and other popular services on the web expose their APIs via SOAP with the RPC/encoded style (Google search).
Nevertheless, from an enterprise development point of view, the lack of doc/lit support is a major drawback.

So, some possible solutions I came up with:
1. Code this myself.
I could try to add doc/lit support to soap4r – solve my problem and make a nice contribution to the community. The main problem with this approach, with regards to my experiment specifically, is that the whole idea was to see if Rails is enterprise-ready, and a better alternative than Java for enterprise development. If I need to invest a lot of time now to implement something that’s already available in Java, that defeats the purpose. Of course, if I did implement and outsource that functionality, then I solved the issue for future generations 

2. Look for libraries other than soap4r/AWS.
Ruby-Amazon could be a good candidate since Amazon’s Alexa Web Search service, which ruby-amazon apparently supports definitely uses doc/lit. The don’t use soap4r, so I might be able to use their code for the basic SOAP support.

I’ll probably try a combination of the two – use the ruby-amazon to speed up my own implementation of a more generic SOAP stack that supports doc/lit. Haven’t decided yet. It’s going to take some more research (and free time).


Joe Litton said...

Elad, This is a very timely experiment you've undertaken. Thank you for blogging the progress and discoveries. Yes, it's all about productivity, so it will be interesting to see what solution you decide to pursue re this first hurdle. Cheers!

Matt said...

Just an FYI. soap4r does support doc/literal. We've been using it for the past 6 months. It's not well documented, possibly because you don't anything different than you would for RPC.

AWS on the other hand, hard-codes into its WSDL response that it's rpc. To be honest since they're using soap4r under the covers, doc/lit may work, you just need to remove the hard coding of rpc in AWS. So you could just run a "Standalone" SOAP4r server (which is using WebBrick under the covers).

You could possibly start up the standalone server via rails through boot.rb Then it'll startup and shutdown (WebBrick traps the kill signal) with rails. It's not perfect, but it's a start.

Elad said...

Thanks for the input, Matt.
I'll give it a try.

Jim said...

matt/elad, I have used the SOAP4R library to talk to a doc\literal web sevice but have not used it to develop a doc/lit soap web service in ruby.

elad, did u manage to get this going?

Elad said...

I don't have a full solution yet, but I have a simple quick-and-dirty one for exposing doc/lit services - simply use rxml to serialize the objects.
As for the schema, I added the schema file one generated by my Java code to my Rails project (yeah, I know, that's a cheat, but it's temporary), and added a link to it from my rxml view.