Skip to content

Instantly share code, notes, and snippets.

@yulgit1
Last active August 29, 2015 14:09
Show Gist options
  • Save yulgit1/b6bad3c6d625ea7610cc to your computer and use it in GitHub Desktop.
Save yulgit1/b6bad3c6d625ea7610cc to your computer and use it in GitHub Desktop.
require 'savon'
handle_wsdl = "http://linktest.odai.yale.edu/ypls-ws/PersistentLinking?wsdl"
handle_prefix = "10079.1/isps"
handle_group = "10079.1/ISPS"
handle_user = "10079.1/ISPS"
handle_credential = "*******"
handle_base = "http://isps.yale.edu/"
#handle_group = "10079.1/DIGCOLL"
#handle_user = "10079.1/DIGCOLL"
#handle_credential = "******"
handle_wsdl = "http://link.odai.yale.edu/ypls-ws/PersistentLinking?wsdl"
handle_prefix = "10079/isps"
handle_group = "10079/ISPS"
handle_user = "10079/ISPS"
pid = handle_prefix + "/1"
envelope_sem = "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
"<env:Body>"+
"<tns:createBatchSemantic xmlns:tns=\"http://ws.ypls.odai.yale.edu/\">"+
"<handlesToValues><map><entry>"+
"<key>"+pid+"</key>"+
"<value>"+handle_base+"</value>"+
"</entry></map></handlesToValues>"+
"<group>"+handle_group+"</group>"+
"<user>"+handle_user+"</user>"+
"<credential>"+handle_credential+"</credential>"+
"</tns:createBatchSemantic></env:Body></env:Envelope>"
envelope_auto = "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
"<env:Body>"+
"<tns:createBatch xmlns:tns=\"http://ws.ypls.odai.yale.edu/\">"+
"<values><item>"+handle_base+"</item></values>"+
"<group>"+handle_group+"</group>"+
"<user>"+handle_user+"</user>"+
"<credential>"+handle_credential+"</credential>"+
"</tns:createBatch></env:Body></env:Envelope>"
puts "Creating handle for pid: " + pid
puts "envelope: " +envelope_auto
puts "wsdl:" + handle_wsdl
client = Savon.client(wsdl: handle_wsdl)
response = client.call(:create_batch, xml: envelope_auto)
if response.success? == true
puts "Created handle(if semantic): http://hdl.handle.net/"+pid
puts "if minted http:/hdl.handle.net/xxxxxxx using response key"
puts "response: " + response.to_xml.to_s
else
puts "Error creating handle for pid: "+ pid
puts "response: " + response.to_xml.to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment