Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created April 5, 2011 19:34
Show Gist options
  • Save rubiii/904347 to your computer and use it in GitHub Desktop.
Save rubiii/904347 to your computer and use it in GitHub Desktop.
Savon InterFAX example: Get an outbound fax image
# more examples at:
# https://gist.github.com/903337
require "rubygems"
require "base64"
# $ gem install savon (works with v0.9.1 and higher)
require "savon"
# convert hash key symbols to camelcase
Gyoku.convert_symbols_to(:camelcase)
# create a client using the InterFAX WSDL
client = Savon::Client.new("http://ws.interfax.net/dfs.asmx?wsdl")
# execute a request to the :get_fax_image action
# this example uses a shortcut to set the SOAP body
response = client.request(:int, :get_fax_image, :body => {
:username => "your username",
:password => "your password",
:transaction_ID => 204420767
})
# translate the response to a Hash and get the image
image = response[:get_fax_image_response][:image]
# decode the image data
image = Base64.decode64(image)
# save the image to disk
File.open("/Users/username/Desktop/fax.tif", "w") { |f| f.write(image) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment