Search code examples
rubyweb-servicessavon

SAVON passing XML as a request to wsdl and getting response as xml


I have a third party application and output of this application is an request xml which needs to be passed in to webservice (WSDL)

I need to do integration testing where i will be getting this request xml.

how can i pass this request xml using savon in Ruby ? is there anyother way where we can pass request xml and get the output in response xml

i tried using soapui and it works but i am looking for native ruby solution


Solution

  • Hello I found the answer and below is the code

    Then (/^I test wsdl$/) do require 'savon'

    require 'nokogiri'
    
    xml_file = File.read("/test.xml")
    
    client = Savon.client(wsdl: '/globalweather.wsdl', ssl_verify_mode: :none, ssl_version: :TLSv1)
    
    response = client.call(:get_cities_by_country, xml: xml_file)
    puts response.to_xml
    print response.to_xml
    

    end