I'm working on a SOAP API which has two operations, and each operation requires API keys and bunch of other attributes. So, I've been able to make request via SOAPUI, but I'm having trouble translating that into ruby code using savon gem(Version 2).
Here's a screenshot of searchTours request.
Now, how do I tranlate it into ruby code using Savon? I tried following, but it didn't work.
client = Savon.client(wsdl: 'url goes here..')
client.operations #=> [:tour_details_full, :search_records]
message = {security_key: "SECURITYKEYS", attributes_one: "ValueOne", attribute_two: IntegerValue}
response = client.call(:search_records, message: message)
Error message:
Savon::SOAPFault: (S:Client) Cannot find dispatch method for {url_here} SearchRecords
You have to do something like this:
class SearchTours
extend Savon::Model
client wsdl: 'your url',
namespaces: {
...
'xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/',
....
...#your namespacecs
}
operations :tour_details_full, :search_records
def self.tour_details_full
builder = Builder::XmlMarkup.new()#describe your request params
super message: builder
end
def self.search_records
builder = Builder::XmlMarkup.new()#describe your request params
super message: builder
end
end
#then you can call
SearchTours.search_records #=> []
also you can user this online tool to checkout your wsdl service or request
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.