使用 Savon gem 在 Ruby 中使用 SOAP 服务

发布于 2024-09-09 09:58:03 字数 793 浏览 9 评论 0原文

我正在尝试使用 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

感谢任何帮助。

I am trying to consume a SOAP service using the Savon gem but having difficulty. I have accessed the SOAP service using soapUI and it works fine.

My code:

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

The error I am getting:

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

Appreciate any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟凡古楼 2024-09-16 09:58:03

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

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

I don't have all the data you need to pass so I couldn't test this. May very well be an issue with this code but at least it will put you on the right path. Hope it helps.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文