Ruby, Ruby on Rails, and SAP Web Services Integration
Something I like about Scripting Languages is the way they revel in having "more than one way to skin a cat". So, in this spirit I have built a complementary interface to saprfc (for Ruby) called sapwas, that facilitates RFC calls via SAP Web Services. This has been integrated into sap4rails, and the attached example demonstrates how to substitue Web Services for RFC integration in Ruby on Rails.
SAP Web Services vs RFC?
Other than curiosity, there is another motivation for trying this out - Since there has been discussion of late on the merits of RFC and Web Service technology such as SOAP, I thought that inorder to do the subject justice I would do some further (tangible) investigation.
To me, the most obvious way to draw a comparison, is to develop comparable examples of each, with the only difference being the substitution of the technology in question.
This led to me focusing on a recent article I wrote: Ruby on Rails with AJAX, to use as a base line.
Activating the SAP Web Service support
If we take the example above (Ruby on Rails with AJAX), then the changes are as follows:
- Install sapwas (version 0.02+)
- Upgrade sap4rails (version 0.04+)
- modify the SapUser model
- set your Rails configuration
Install sapwas
Download either the source distribution, or the gem file by following the sapwas project download links. Gem files are easier to deal with - all you need to do is:
gem install sapwas-<version>.gem
And its done (use gem uninstall to remove if its there allready).
You will probably need to install http-access2 inorder to get the basic authentication working correctly. This is a requirement of the SOAP4R library.
Upgrade sap4rails
Download either the source distribution, or the gem file for sap4rails by following the project download links. First remove the old version, and install the new:
gem uninstall sap4rails gem install sap4rails-<version>.gem
If you have used the source distribution previously, then you will have to manually remove the previous one, and install again (the usual ruby setup.rb dance - gems are soo much easier :-).
Modify the SapUser model
In the Rails application, edit the app/models/sap_user.rb, and change the super class for SapUser:
class SapUser < SAP4Rails::WS::Base ...
Set your Rails configuration
Modify the config/sap.yml file - you really should only need to add in the :url line depicted below, but check anyway:
client: "010" url: "http://seahorse.local.net:8000/sap/bc/soap/rfc" user: developer passwd: developer lang: EN
note on WAS configuration
You must ensure that /sap/bc/soap/rfc is configured/activated correctly in transaction SICF.
Go!
Once you have completed these changes, you can then test the Rails application as described in Ruby on Rails with AJAX - it should function in exactly the same manner - wasn't that easy!
Now you have it working - I'll leave you to draw your own conclussions on it's merits :-)
Posted by PiersHarding at October 15, 2006 6:11 PM