SOAP端点url通过ruby for Java SOAP Client

时间:2016-08-10 05:12:53

标签: java ruby soap soap-client soap4r

我尝试使用Java SOAP Client调用Ruby SOAP Web服务。我无法得到这个网址的回复:

http://localhost:8080/calculation?wsdl 

(我担心以上网址服务的上述端点网址是错误的)

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

我收到的错误为:

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)

端点网址是否错误?我使用Rub Client调用它(diff url)。有没有办法使用JAVA Client调用?

Ruby SOAP客户端:

#!/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

0 个答案:

没有答案