-
-
Save bmoussaud/4c2b728d263c6277192b to your computer and use it in GitHub Desktop.
Savon Client for SDM webservices - Request examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'savon' | |
# Get wsdl | |
client = Savon.client(wsdl: "http://localhost:8080/axis/services/USD_R11_WebService?wsdl") | |
#login | |
response = client.call(:login, message: {username: "servicedesk", password: ""}) | |
sid = response.body[:login_response][:login_return] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'savon' | |
# Get wsdl | |
client = Savon.client(wsdl: "http://localhost:8080/axis/services/USD_R11_WebService?wsdl") | |
#login | |
response = client.call(:login, message: {username: "servicedesk", password: ""}) | |
sid = response.body[:login_response][:login_return] | |
#DoQuery and get a list handle | |
response = client.call(:do_query, message: { sid: sid, object_type: "cr", where_clause: "ref_num='273043'"}) | |
list_handle = response.body[:do_query_response][:do_query_return][:list_handle] | |
#parse list hancle | |
response = client.call(:get_list_values, message: { sid: sid, list_handle: list_handle, start_index: "0", end_index: "-1", attribute_names: ["persistent_id"]}) | |
response.body[:get_list_values_response][:get_list_values_return] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'savon' | |
# Get wsdl | |
client = Savon.client(wsdl: "http://localhost:8080/axis/services/USD_R11_WebService?wsdl") | |
#login | |
response = client.call(:login, message: {username: "servicedesk", password: ""}) | |
sid = response.body[:login_response][:login_return] | |
#Set attributes | |
attrVals = {"string" => ["summary","A new incident", "description", "new incident with NSM trigram", "category", "pcat:440622", "customer", "1214398A2FA05F4C94B7A1BFAFB2488C", "type", "I", "ztrigram", "400077"]} | |
prop = {"string" => [""]} | |
attributes = {"string" => ["persistent_id"]} | |
requestHandle = "" | |
requestNumber = "" | |
#Create incident | |
response = client.call(:create_request, message: {sid: sid, creatorHandle: "", "attrVals" => attrVals, "propertyValues" => prop, "template" => "", "attributes" => attributes, "newRequestHandle" => requestHandle, "newRequestNumber" => requestNumber}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'savon' | |
# Get wsdl | |
client = Savon.client(wsdl: "http://localhost:8080/axis/services/USD_R11_WebService?wsdl") | |
#login | |
response = client.call(:login, message: {username: "servicedesk", password: ""}) | |
sid = response.body[:login_response][:login_return] | |
#Set attributes | |
attributes = {"string" => ["persistent_id"]} | |
attrVals = {"string" => ["summary","new summary updated with webservices"]} | |
#update object sumary | |
response = client.call(:update_object, message: {sid: sid, objectHandle: "cr:581141", "attributes" => attributes, "attrVals" => attrVals}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'savon' | |
client = Savon::Client.new(wsdl: "http://192.168.0.109:8080/axis/services/USD_R11_WebService?wsdl") | |
# Create issue | |
create_issue = client.request(:create_issue) do |soap| | |
soap.body = { | |
:in0 => token, | |
:in1 => { | |
:type => "1", | |
:project => project, | |
:summary => "Jira SOAP API Test #1", | |
:description => "This slip was created using Jira's SOAP API", | |
:components => {'Math' => {'id' => '16420', 'name' => 'Math'}}, | |
:customFieldValues => [{'customfieldId' => 'customfield_11630', 'values' => ['estimate']}] | |
} | |
} | |
end | |
#Make list Request | |
response = client.call(:get_handle_for_userid, message: { sid: sid, userid: "servicedesk"} | |
#Example soap request | |
response = client.request :echo, "EchoRequest", :body => { "Message" => "Hello from Ruby" } do | |
# The EchoService has its messages in a different namespace than the | |
# targetNamespace of the WSDL, specify it here to have the request | |
# rendered properly | |
soap.namespaces["xmlns:echo"] = "http://www.without-brains.net/echo" | |
end | |
data = response.to_array(:echo_response).first | |
puts "EchoService responded to Echo: #{data[:message]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment