0

I'm trying to invoke a Ruby SOAP Web Service using Java SOAP Client. And I am unable to get the response for this url:

http://localhost:8080/calculation?wsdl 

(I'm afraid if the above endpoint url is wrong for the below web service)

Ruby SOAP WS:

require "soap/rpc/standaloneserver"

begin
  class MyServer < SOAP::RPC::StandaloneServer

    # Expose our services
    def initialize(*args)
      super
      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("MyServer",
                        'urn:ruby:calculation', 'localhost', 8080)
  trap('INT'){
    server.shutdown
  }
  server.start
rescue => err
  puts err.message
end

I'm getting the error as :

in `success_content': unexpected response: #<HTTP::Message::Headers:0x00000004328c10 @http_version="1.1", @body_size=0, @chunked=false, @request_method="GET", @request_uri=#<URI::HTTP http://localhost:8080/calculation?wsdl>, @request_query=nil, @request_absolute_uri=nil, @status_code=405, @reason_phrase="Method Not Allowed ", @body_type=nil, @body_charset=nil, @body_date=nil, @body_encoding=#<Encoding:ISO-8859-1>, @is_request=false, @header_item=[["Allow", "POST"], ["Content-Type", "text/html; charset=ISO-8859-1"], ["Server", "WEBrick/1.3.1 (Ruby/2.2.5/2016-04-26)"], ["Date", "Wed, 10 Aug 2016 05:02:29 GMT"], ["Content-Length", "297"], ["Connection", "close"]], @dumped=false> (HTTPClient::BadResponseError)

Is the endpoint url wrong? I invoked with the Rub Client and it worked (diff url). Is there a way to invoke using JAVA Client?

Ruby SOAP Client:

#!/usr/bin/ruby

require 'soap/rpc/driver'

NAMESPACE = 'urn:ruby:calculation'
URL = 'http://localhost:8080/'

begin
  driver = SOAP::RPC::Driver.new(URL, NAMESPACE)

  # Add remote sevice methods
  driver.add_method('add', 'a', 'b')

  # Call remote service methods
  puts driver.add(200, 130)
rescue => err
  puts err.message
end
enigma
  • 93
  • 1
  • 10

0 Answers0