Skip to content

Instantly share code, notes, and snippets.

@fs
Created April 15, 2010 11:44
Show Gist options
  • Save fs/367002 to your computer and use it in GitHub Desktop.
Save fs/367002 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'savon'
require 'xmlsimple'
require 'pp'
# force SOAP 1.2
Savon::SOAP.version = 2
get_client = Savon::Client.new('https://ai360.aristotle.com/API2/getIndividualInfoAPI/getIndividualInformationWebService.asmx?WSDL')
set_client = Savon::Client.new('https://ai360.aristotle.com/API2/setIndividualInfoAPI/setIndividualInformationWebService.asmx?WSDL')
credentials = {
'wsdl:strUserName' => 'Sean.santry',
'wsdl:strPassword' => 'Santrytest1'
}
# forse name space for getDetail tags b/c aristotle need them. don't know why
response = get_client.get_detail do |soap|
soap.body = {
'wsdl:strIndividualGUID' => '11111111-1111-1111-1111-111111111111',
}.update(credentials)
end
# is it ok?
exit(response.soap_fault) if response.soap_fault?
puts '============================'
puts response.to_xml
# XmlSimple could translate xml to hash and back with out changes
hash_response = XmlSimple.xml_in(response.to_xml, { 'KeepRoot' => false })
# you could make some changes in this hash
hash_schema = hash_response['Body'].first['getDetailResponse'].first['getDetailResult'].first['schema'].first
hash_diffgramm = hash_response['Body'].first['getDetailResponse'].first['getDetailResult'].first['diffgram'].first
# convert back to the xml
xml_schema = XmlSimple.xml_out(hash_schema, { 'RootName' => 'xs:schema', 'NoIndent' => false})
xml_diffgramm = XmlSimple.xml_out(hash_diffgramm, { 'RootName' => 'diffgr:diffgram', 'NoIndent' => false})
set_client.set_detail do |soap|
soap.namespaces['xmlns:xsd'] = 'http://www.w3.org/2001/XMLSchema'
soap.body = <<-XML
<wsdl:dstInputDataSet>
#{xml_schema}
#{xml_diffgramm}
</wsdl:dstInputDataSet>
#{credentials.to_soap_xml}
XML
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment