Savon, XML, SOAP help...

5 views
Skip to first unread message

Allen Maxwell

unread,
Jul 1, 2016, 12:48:52 PM7/1/16
to ur...@googlegroups.com
Hi All,

I’m working on a quick project to fix an issue in an old legacy system which handles buying domains using a Godaddy reseller API.  
I haven’t done much with XML but I seem to be wading through Nokogiri without too much trouble.  I have done no SOAP before and I’m new to SAVON.

I have been able to connect to the server and authenticate.  I’ve also been able to run some simple commands.  So I’m getting there… I have a question that maybe someone can help me with:


let’s assume the SOAP request is supposed to look like this:

   <soapenv:Header/>
   <soapenv:Body>
      <web:CheckAvailability>
         <!--Optional:-->
         <web:sCLTRID>a_guid_i_made</web:sCLTRID>
         <!--Optional:-->
         <web:credential>
            <!--Optional:-->
            <web:Account>myaccount_number</web:Account>
            <!--Optional:-->
            <web:Password>my_password</web:Password>
         </web:credential>
         <!--Optional:-->
         <web:sDomainArray>
            <!--Zero or more repetitions:-->
            <web:string>mystupidmaxwellsite.com</web:string>
            <web:string>example.biz</web:string>
         </web:sDomainArray>
         <!--Optional:-->
         
      </web:CheckAvailability>
   </soapenv:Body>
</soapenv:Envelope>


I’m using the SAVON gem and here’s some code that works for a describe method call…

require 'savon'
require 'securerandom'
require 'nokogiri'



guid = SecureRandom.uuid


@ote_wsdle = "https://api.ote.wildwestdomains.com/wswwdapi/wapi.asmx?wsdl"
@prod_wsdle = "https://api.wildwestdomains.com/wswwdapi/wapi.asmx?wsdl"
creds = { 'Account' => myacctnum", 'Password' => “my password" }
@url = '173.201.195.69'

client = Savon.client(wsdl: @ote_wsdle,
pretty_print_xml: true)

cred_hash ={"sCLTRID": guid, :credential => creds }
response = client.call(:describe, message: cred_hash)

unless response.success?
puts
"\n\n******************\nFAILED: #{response.to_hash}\n******************\n\n\n"
exit
end

puts "Describe is ok..."
————————— end of code

In the SOAP example above there is this section:
         <web:sDomainArray>
            <!--Zero or more repetitions:-->
            <web:string>mystupidmaxwellsite.com</web:string>
            <web:string>example.biz</web:string>
         </web:sDomainArray>

it calls for “zero or more repetitions” for basically an array of sites to check…  I tried this:

@sites_to_check = [example.us, example.biz, asitenoonewouldusesdflkjsdflsj.com']
msg_hash = cred_hash
msg_hash["sDomainArray"] = [{string: @sites_to_check[0]}, {string: @sites_to_check[1]}, {string: @sites_to_check[2]}]
response = client.call(:check_availability, message: msg_hash)

——— end code

this seems to process the first site but none of the others in the array.  How should I code this where I need to send an array under the sDomainArray key?  

any ideas would be helpful and thanks!

Max







Reply all
Reply to author
Forward
0 new messages