As discussed elsewhere the SOAP::RPC::Driver which was available in Ruby 1.8 has been removed in Ruby 1.9. People suggested using the Savon gem, but I can’t find any tutorials on how to convert existing code, specifically for endpoints for which there is no WSDL available.
For example, with SOAP::RPC::Driver we could write:
require 'soap/rpc/driver'
client = SOAP::RPC::Driver.new 'http://example.com/endpoint', 'MY_NAMESPACE'
Add methods (since in my case I have no WSDL available):
client.add_method 'MyMethod', 'Arg1', 'Arg2'
And then call them:
response = client.MyMethod arg_one arg_two
I don’t see how to add methods like this with Savon.
When not using a WSDL one must set up
wsdlexplicitly (I find this a little counter-intuitive, but it works):I don’t believe there is an equivalent to
add_methodin Savon, but you should then be able to make a request thus:However when I did this I received the following error:
I was able to work around this by explicitly setting
SOAPAction:Finally I got this error:
This seems to be because the given
wsdl.namespaceisn’t passed as expected with the request. I was able to resolve this by explicitly setting it in bothsoap_actionandxmlns: