红宝石 &Savon SOAP 客户端 - 无法找到 SOAP 操作 [英] Ruby & Savon SOAP client - Unable to find SOAP operation

查看:27
本文介绍了红宝石 &Savon SOAP 客户端 - 无法找到 SOAP 操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一次使用 SOAP 客户端,所以不确定我在这里做错了什么.

First time working with a SOAP client, so not sure what I'm doing wrong here.

这是我尝试使用的 SOAP API:http://services.carsolize.com/BookingServices/DynamicDataService.svc?wsdl

Here's the SOAP API I'm trying to use: http://services.carsolize.com/BookingServices/DynamicDataService.svc?wsdl

irb(main):018:0> client = Savon.client(wsdl: "http://services.carsolize.com/BookingServices/DynamicDataService.svc?wsdl", convert_request_keys_to: :camelcase)

无论我传递给 client 上的 call 什么,它都会告诉我:

No matter what I pass to call on client, it tells me:

irb(main):022:0> client.call :service_request, :message => {}
HTTPI GET request to services.carsolize.com (net_http)
Savon::UnknownOperationError: Unable to find SOAP operation: :service_request
Operations provided by your service: []
    from /var/lib/gems/1.9.1/gems/savon-2.2.0/lib/savon/operation.rb:22:in `ensure_exists!'
    from /var/lib/gems/1.9.1/gems/savon-2.2.0/lib/savon/operation.rb:14:in `create'
    from /var/lib/gems/1.9.1/gems/savon-2.2.0/lib/savon/client.rb:32:in `operation'
    from /var/lib/gems/1.9.1/gems/savon-2.2.0/lib/savon/client.rb:36:in `call'
    from (irb):22
    from /var/lib/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
    from /var/lib/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
    from /var/lib/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我了解 SOAP 服务未报告任何操作.有没有办法解决?是我这边的什么东西把它搞砸了,还是网络服务?

I understand that the SOAP service isn't reporting any operations. Is there any way around this? Is it something on my side that's messing it up, or is it the web service?

Savon 版本:2.2.0

Savon version: 2.2.0

推荐答案

Savon 2.x.x 可以在没有 WSDL 的情况下访问 Web 服务.我检查了您随 SoapUI 提供的 WSDL,并使用输出创建了以下代码片段.

Savon 2.x.x can access a Web Service without a WSDL. I inspected the WSDL you provided with SoapUI and used the output to create the following code snipped.

它不起作用,因为我显然没有正确的凭据,但它应该让您知道从哪里继续.

It doesn't work because I obviously haven't the correct credentials but it should give you the idea where to continue.

#!ruby
#
gem 'savon', '~> 2.0'
require 'savon'

client = Savon.client(
    endpoint: 'http://services.carsolize.com/BookingServices/DynamicDataService.svc',
    soap_action: "http://tempuri.org/IDynamicDataService/ServiceRequest",
    namespace: 'http://tempuri.org/',
    convert_request_keys_to: :camelcase,
    env_namespace: :soapenv,
    namespace_identifier: :tem,
    log: true,
    log_level: :debug,
    pretty_print_xml: true
)

response = client.call(:service_request,
                       message: {
                          'tem:rqst' => {
                            'BookAsUser' => 'nobody',
                            'Credentials' => {
                              'Password' => 'super secret',
                              'UserName' => 'JoeSixpack'
                            },
                            'Request' => {
                              'ClientIP' => '192.168.142.857'
                            },
                            'RequestType' => 'reservation',
                            'SessionID' => 'AAAAAAAAAAAAAABBBBBBBBBBBBB',
                            'TypeOfService' => 'speedy'
                          }
                       }
                      )
 p response.to_hash

这篇关于红宝石 &amp;Savon SOAP 客户端 - 无法找到 SOAP 操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆