Although I have to hack httpclient (I know there must be a way not to hack it!). Some if not most of the posts/tutorials out there might or might not work. So here's how I got it working.
I have to implement this functionality requiring to invoke a web service. The developer I was working with gave me a rpc/encoded wsdl file (as oppose to a document literal). (What's the fuzz is rpc/encoded & document literal???)
Now there are two ways to use soap4r: read the wsdl at runtime and invoke its method(s) dynamically or create the stubs with your local wsdl file. In my case, I chose to create the stubs (consumer) using wsdl2ruby which comes with soap4r. Here's how you can install soap4r and generate the stubs.
Now for the fun part ...
- If you start your rails app and fails because of jruby-openssl missing, you probably need to modify ssl_config.rb and set SSLEnabled to false (from httpclient gem). httpclient is a dependency of soap4r.
- As mentioned above, soap4r generates you .rb files (4 of them), you actually only need the *driver.rb in your code. To give you an idea how to use it, have a look at the generated client stub (*Client.rb).
- Authentication => Since the web service I was trying to invoke requires me to do basic authentication, I have to pass in options to my driver object.
- Testing => so aside from doing your unit test, what I found helpful was testing the web service using soapUI. soapUI generates a service request as well as a dummy service for you based on your wsdl file. There are many tutorials out there that would surely help you.