Home>

In Rails6, I want to run a ruby ​​file that runs on rails runner as a SOAP client.
At that time, I would like to use the wsdl file prepared by the local Rails project. How should I specify it?
Please teach me.

What I tried

Run the following Ruby file as SOAP client and rails runner.

Rails project /sample/test.rb

Regarding SOAP,This siteI referred to.

For example, if you put the wsdl file locally as below

Rails project /sample/sample.wsdl


How do I write this wsdl file?

Since the URL was specified on the referenced site, please teach us how to specify it locally.

client = Savon.client (wsdl:'http://service.example.com?wsdl')
Supplementary information (FW/tool version, etc.)

Ruby on Rails 6

Postscript

I made a ruby ​​file [Rails project /sample/test.rb] of SOAP client as follows.

require "savon"
class Test
    def execute
        client = Savon.client (wsdl: "http: // localhost: 3000/test_soap? sample.wsdl")
        client.operations # A list of available operations appears
        response = client.call (: find_user, message: {id: 42}) It seems that id 42 is fetched by the operation # find_user.
        response.body # HTTP response body, hash contains values.
        puts response
    end
end
test = Test.new
test.execute

Then, the following error appears. What should I do?

$rails runner sample/test.rb
Traceback (most recent call last):
        22: from bin/rails: 9: in `<main>'
        21: from C: /Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb: 291: in `require'
(Omitted)
         2: from C: /Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb: 257: in `load_dependency'
         1: from C: /Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291: in `block in require'
C: /Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32: in `require': cannot load such file - savon (LoadError)

If i check it, it behaves like a gem savon is included.

$gem list savon
*** LOCAL GEMS ***
savon (2.12.1)