我正在尝试使用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
感谢任何帮助。
答案 0 :(得分:2)
我没有你需要通过的所有数据,所以我无法测试。这个代码很可能是一个问题,但至少它会让你走上正确的道路。希望它有所帮助。
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