4

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.

enter image description here

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

Rahul Roy
  • 473
  • 1
  • 6
  • 17
  • Is it a DOTNET webservice? That can mean you have to name explicitely the soap_action. – Steffen Roller Nov 20 '14 at 18:36
  • I don't know, but let me try that soap_action thing. I'll report back as soon as I can. – Rahul Roy Nov 20 '14 at 20:11
  • This seems like a config issue, so might double check Savon docs to ensure you did all of that correctly. Also, this similar question might have an answer if you have not seen it yet, in particular make sure you end the url with slash: http://stackoverflow.com/q/7478406/398696 – d3vkit Nov 22 '14 at 18:32

1 Answers1

0

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

ajahongir
  • 469
  • 5
  • 11