SOAP using soap4r Ruby

572 views Asked by At
I implemented a standalone server with the help of this tutorial:
http://www.tutorialspoint.com/ruby/ruby_web_services.htm

The code is :

require "soap/rpc/standaloneserver"

begin
   class MyServer < SOAP::RPC::StandaloneServer

      # Expose our services
      def initialize(*args)
        super(args[0], args[1], args[2], args[3])
         add_method(self, 'add', 'a', 'b')
         add_method(self, 'div', 'a', 'b')
      end

      # Handler methods
      def add(a, b)
         return a + b
      end
      def div(a, b)
         return a / b
      end
  end
  server = MyServer.new("soapservice", 'soapservice', 'localhost', 8080)

  trap('INT'){server.shutdown  }
  server.start
rescue => err
  puts err.message
end

When I try to access it from a browser by pointing to localhost:8080 its gives me the following error "[2013-08-08T16:31:19.040360 #4840] ERROR -- soapservice: GET request not allowed". I have tried accessing it via POST but still the same problem. Can anyone please tell me whats the correct URL I should be using to consume this web service?

1

There are 1 answers

0
smenon On

try to add this to top

require 'rubygems'
#gem 'soap4r'
gem 'soap4r-ruby1.9'
require 'soap/rpc/standaloneServer'
require 'builder'