Who are we?

We are a group of enthousiastic people working for Nedap, a Dutch company with a single goal: solve problems.

Search

Entries in SOAP (1)

Tuesday
May082007

Ruby + SOAP + Multiple servers

The tutorials make it sound so easy. Plug and play even. Unfortunately reality (as always) bites hard.

SOAP integration is a piece of cake if you have one server and no authentication, but when you do the trouble starts. Although the problem is easy to solve once you know how, the lack of documentation on the subject is annoying.

Ruby's current SOAP implementation supports basic http authorisation during communication, however it does not support getting the WSDL file trough the same authorisation... (Argh! 1 ) So you have to pre-fetch the WSDL file and store it as a file, since Ruby does not support reading the WSDL file from a string (Argh! 2).

Since we have multiple servers running the same application on different ports the cached WSDL file is never correct...(Argh! 3) We solve this by overriding the WSDL's proxy setting.

The final code is short but it took me a while to find all this stuff out so I thought i'd post it here:

require 'soap/wsdlDriver'

# Connection settings
url   = "http://testingserver:3000/webservice"
usr  = "***"
pw  = "***"

wsdl_file = "wsdl/cached_file.wsdl"

factory = SOAP::WSDLDriverFactory.new(wsdl_file).create_rpc_driver
factory.options["protocol.http.basic_auth"] << [ url, usr, pw ]
factory.options["protocol.http.ssl_config.verify_mode"] = nil
factory.proxy.endpoint_url = url