#Requires Ruby version 1.8.5 or highet
require 'soap/wsdlDriver'
wsdl = 'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'
driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
# Log SOAP request and response
driver.wiredump_file_base = "soap-log.txt"
response = driver.IsValidISBN13(:sISBN => '0000000000000')
puts response.isValidISBN13Result
Let's examine the code a bit more.
The first part brings in the required headers, namely soap/wsdlDriver
We then declare a variable wsdl to point to the web service description. The wsdl allows the client code to understand what method are available and how to call them.
We then turn on some debugging, this is optional but if its your first time I recommend it.
drive.isValidISBN13 actually exectues our call. Based on the wsdl it knows how to serialize the call and get back the results which I store in the 'response' variable.
That's It.
I found Ruby to be one of the easiest languages to make a web call from. It doesn't require building any complex wrappers and has all the libraries built it.
If you have any trouble getting it working, leave a comment and I'll be happy to take a look.
For more information about Ruby and Web Services I recommend Ruby Cookbook (Cookbooks (O'Reilly)).
No comments:
Post a Comment