我正在尝试使用Savon gem来使用SOAP服务,但遇到了困难我使用soapui访问了soap服务,它工作得很好。
我的代码:

require 'rubygems'
require 'savon'

# Client instance with a WSDL endpoint
client = Savon::Client.new "http://realtime.nationalrail.co.uk/ldbws/wsdl.aspx"

p client.wsdl.namespace_uri

p client.wsdl.soap_actions

response = client.get_arrival_board

我得到的错误是:
D, [2010-07-13T11:38:58.967684 #3909] DEBUG -- : Retrieving WSDL from: http://realtime.nationalrail.co.uk/ldbws/wsdl.aspx
"http://thalesgroup.com/RTTI/2008-02-20/ldb/"
[]
/home/abcb293/.gem/ruby/1.8/gems/savon-0.7.9/lib/savon/client.rb:92:in `method_missing': undefined method `get_arrival_board' for #<Savon::Client:0xb7597218> (NoMethodError)
    from natrail.rb:11

谢谢你的帮助。

最佳答案

我没有你需要通过的所有数据,所以我无法测试。这段代码很可能有问题,但至少会让您走上正确的道路希望有帮助。

require 'rubygems'
require 'savon'

wsdl = "http://realtime.nationalrail.co.uk/ldbws/wsdl.aspx"
token = "replace with your data"
numRows = "replace with your data"
crs = "replace with your data"
filterCrs = "replace with your data"
filterType = "replace with your data"
timeOffset = "replace with your data"

# Client instance with a WSDL endpoint
client = Savon::Client.new wsdl
request = client.get_arrival_board { |soap|
soap.namespaces["xmlns:typ"] = "http://thalesgroup.com/RTTI/2010-04-26/ldb/types"
soap.header = {"com:AccessToken" => ["com:TokenValue" => token]}
  soap.body = {
 "typ:GetArrivalBoardRequest" =>[
      "typ:numRows" => numRows,
      "typ:crs" => crs
   "typ:filterCrs" => filterCrs
   "typ:filterType" => filterType
   "typ:timeOffset" => timeOffset]
   }.to_soap_xml
}
puts request

关于ruby - 使用Savon gem在Ruby中使用SOAP服务,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3236355/

10-09 05:48