Skip to content

Instantly share code, notes, and snippets.

@arieliten
Created April 10, 2013 21:05

Revisions

  1. arieliten created this gist Apr 10, 2013.
    63 changes: 63 additions & 0 deletions api_test.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    require 'rubygems'
    gem 'savon', '=1.1.0'
    require 'savon'

    WSDL_URL = "https://testenv.w-w-i-s.com/hb/51/api.asmx?wsdl"
    HMAC = 'string'
    CLIENT_ID = 'AHHRV'
    MAIN_HEADER = {
    'Credentials' => {
    'HMac' => HMAC,
    'ClientID' => CLIENT_ID,
    'UserName' => 'ariel1234',
    'Password' => 'worldwide1'
    }
    }

    puts "Testing connection to endpoint API: '#{WSDL_URL}' ..."
    client = Savon.client do |wsdl, http|
    wsdl.document = WSDL_URL
    http.auth.ssl.verify_mode = :none
    end

    # Showing operations
    operations = client.wsdl.soap_actions
    puts "The operations available to call on this endpoint are:"
    operations.each do |op|
    puts "\t+ #{op}"
    end

    # === Get Accounts ===
    # <soap:Envelope xmlns="http://www.w-w-i-s.com/hb/51"
    # xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    # xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    # xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
    # <soap:Header>
    # <Credentials>
    # <HMac>string</HMac>
    # <ClientID>AHHRV</ClientID>
    # <UserName>ariel1234</UserName>
    # <Password>worldwide1</Password>
    # <!--<SessionKey>3ucvciuejbtf1yeu4fpsnfuj</SessionKey>-->
    # </Credentials>
    # </soap:Header>
    # <soap:Body>
    # <GetAccounts>
    # <accttype>All</accttype>
    # <skiprefresh>false</skiprefresh>
    # </GetAccounts>
    # </soap:Body>
    # </soap:Envelope>



    body = {
    'GetAccounts' => {
    'accttype' => "All",
    'skiprefresh' => 'false'
    }
    }
    response = client.request :soap, :get_accounts do
    soap.header = MAIN_HEADER
    soap.body = body
    end