XWeb: Ruby
Issues with Ruby
Ruby comes with a package called soap4r which includes several ways of accessing a service and a few utilities that may be of use:
- xsd2ruby - A tool that will read an XML Schema Definition (XSD) and create classes from the defined entities.
- wsdl2ruby - This tool extends the xsd2ruby tool to include creating wrapper classes for the service calls.
soap4r is still under development, and if there are any problems passing variables or reading responses upgrading to the latest version may help.
Basic SOAP with Ruby
require 'soap/wsdlDriver'
service = SOAP::WSDLDriverFactory.new("http://someurl/WSDL").create_rpc_driver
service.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
result = service.GetIndividualInformation({'IndividualKey'=>"292aaf95-6f9c-4d89-bee0-6a8f6877c7a9"})
print("Result: ",result.inspect,"\n\n")
#Note that when using the wsdl the result comes in an object called RequestNameResult, as opposed to the response using the bare request below
print result['GetIndividualInformationResult']['IndividualObjects']['IndividualObject']['ind_first_name']+"\n"
#Since variables with leading capital letters are special in ruby, the soap mapping lowercases the first letter
#either style of access works fine, it is individual preference
print result.getIndividualInformationResult.individualObjects.individualObject.ind_first_name+"\n"
Calling Authenticate with Ruby
To see an example showing how to use Ruby to set and get the Soap headers see the xWeb:Authenticate Ruby Sample1 page.
See Also
xWeb: Authenticate Ruby Sample 1
Integrate Ruby on Rails with Avectra's netFORUM xWeb API by Todd Lockhart at AUDC 2012.