I’m trying to connect to a SOAP API that sits in a DMZ behind a firewall using a Ruby/Rack app and the Savon gem for SOAP, and HTTPI gem for requests/responses.
The SOAP API defines a wsdl file that points to an internal domain name behind the firewall (eg. “http://randomhostname/path/to/wsdl”), and that works fine when I define the ip to hostname in my /etc/hosts file locally on my machine (1.1.1.1 randomhostname).
The problem I run into, is that the production environment for my app runs on Heroku.
How can I map the external ip of the server I’m trying to connect to with the hostname defined in the wsdl on Heroku or in my application?
Don’t use the WSDL. Call the functions directly. Like this:
#!ruby require 'savon' stock_handle = ARGV[0] || 'OTEX' client = Savon::Client.new do wsdl.endpoint = 'http://www.webservicex.net/stockquote.asmx' wsdl.namespace = 'http://www.webserviceX.NET/' end response = client.request :wsdl, 'GetQuote' do http.headers["SOAPAction"] = '"http://www.webserviceX.NET/GetQuote"' soap.body = { "symbol" => stock_handle } end print response