Savon,Wasabi将Ruby脚本连接到SOAP URL时出错 [英] Savon, Wasabi Error when connecting a Ruby script to a SOAP url
问题描述
我正在尝试使用Ruby脚本连接到SOAP URL.
Im trying to connect to a SOAP URL with a Ruby script.
我正在关注此 Railscasts集.我安装了savon gem(savon(2.4.0)).
I am following this Railscasts episode. I installed the savon gem(savon (2.4.0)).
然后在我的ruby文件中,我有以下代码:
Then in my ruby file I have this code:
require 'savon'
client = Savon.client(wsdl:"https://api.comscore.com/KeyMeasures.asmx?WSDL")
response = client.call(:authenticate , message: { username:"xxxxx", password:"xxxxx"})
puts "#{response.inspect}"
我知道网址没有问题,因为我使用了 SOAPUI 并将WSDL URL放在此处,我得到了响应.
I know there is no issue with the url because I used SOAPUI and placed the WSDL URL there and I got back a response.
运行上面的ruby文件时,出现以下异常:
When I run the ruby file above I get the following exception:
/Users/XXXX/.rvm/gems/ruby-2.0.0-p247/gems/wasabi-3.2.3/lib/wasabi/resolver.rb:44:in `load_from_remote': Error: 401 (Wasabi::Resolver::HTTPError)
from /Users/XXXXX/.rvm/gems/ruby-2.0.0-p247/gems/wasabi-3.2.3/lib/wasabi/resolver.rb:32:in `resolve'
谷歌搜索之后,我看到了这篇帖子,这似乎表明我应该安装并需要gem我做了"httpclient",然后再试一次.没有变化,仍然出现相同的错误.
After googling about I saw this post, which seems to suggest that I should install and require gem "httpclient" which I did and then tried again. No changes, Still getting the same error.
有人可以帮我忙吗.....
Can someone give me a hand as to how to proceed .....
谢谢
推荐答案
我试图从命令行使用curl
访问您提供的WSDL.我无法访问未经授权的WSDL b/c.我想您首先必须提供凭据,这是您的https请求的一部分.这就是wasabi
失败的原因.它找不到WSDL文档.
I tried to access the WSDL you provided using curl
from the commandline. I cannot access the WSDL b/c I'm not authorized. I guess that first you have to provide the credentials as part of your https request. That's why wasabi
fails. It cannot find the WSDL document.
根据可以通过在客户端创建过程中注入以下代码来完成的文档:
According to the documentation that can be done by injecting the following code into your client creation:
client = Savon.client(wsdl: ...,
basic_auth: [ 'username', 'password' ],
log: true,
log_level: :debug,
pretty_print_xml: true)
client.call(...)
这篇关于Savon,Wasabi将Ruby脚本连接到SOAP URL时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!