gpt4 book ai didi

Ruby Savon 身份验证

转载 作者:数据小太阳 更新时间:2023-10-29 08:12:39 25 4
gpt4 key购买 nike

我正在尝试使用 Savon gem 连接到网络服务。我对服务的了解:

  • wsdl 文件 url ".../service.svc?wsdl"
  • 登录“登录”
  • 密码“密码”
  • 域“域”

我通过 SoapUI 成功连接到服务。我在 GUI 中输入了 wsdl url、登录名、密码和域,文档如下所示:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:irc="(...url...)">
<soapenv:Header/>
<soapenv:Body>
<irc:MyService>
<irc:request>
<irc:Id>1</irc:Id>
</irc:request>
</irc:MyService>
</soapenv:Body>
</soapenv:Envelope>

现在我正在尝试通过 Savon 进行连接:

require "savon"
client = Savon.client(
wsdl: ".../service.svc?wsdl",
ntlm: ["login", "password", "domain"]
)
client.call(:my_service, message: {id: 1})

产生此错误的原因:

D, [2013-09-11T15:57:59.880241 #12078] DEBUG -- : HTTPI GET request to xxx.yyy.zz (net_http)
/home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/wasabi-3.2.0/lib/wasabi/resolver.rb:44:in `load_from_remote': Error: 401 (Wasabi::Resolver::HTTPError)
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/wasabi-3.2.0/lib/wasabi/resolver.rb:32:in `resolve'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/wasabi-3.2.0/lib/wasabi/document.rb:139:in `xml'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/wasabi-3.2.0/lib/wasabi/document.rb:157:in `parse'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/wasabi-3.2.0/lib/wasabi/document.rb:144:in `parser'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/wasabi-3.2.0/lib/wasabi/document.rb:61:in `soap_actions'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/operation.rb:21:in `ensure_exists!'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/operation.rb:14:in `create'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/client.rb:32:in `operation'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/client.rb:36:in `call'
from test.rb:8:in `<main>'

当我不使用域时:

...
ntlm: ["login", "password"]
...

我得到不同的(正确的?)错误:

D, [2013-09-11T18:58:58.702774 #16226] DEBUG -- : HTTPI GET request to (...url...) (net_http)
I, [2013-09-11T18:58:58.870213 #16226] INFO -- : SOAP request: (...url...)
I, [2013-09-11T18:58:58.870341 #16226] INFO -- : SOAPAction: "(...url...)", Content-Type: text/xml;charset=UTF-8, Content-Length: 350
D, [2013-09-11T18:58:58.870436 #16226] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="(...url...)" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:MyService><id>1</id></tns:MyService></env:Body></env:Envelope>
D, [2013-09-11T18:58:58.870577 #16226] DEBUG -- : HTTPI POST request to (...url...) (net_http)
I, [2013-09-11T18:58:59.173536 #16226] INFO -- : SOAP response (status 401)
D, [2013-09-11T18:58:59.173642 #16226] DEBUG -- :
/home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/response.rb:86:in `raise_soap_and_http_errors!': HTTP error (401) (Savon::HTTPError)
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/response.rb:14:in `initialize'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/operation.rb:64:in `new'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/operation.rb:64:in `create_response'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/operation.rb:55:in `call'
from /home/juraj/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.3.0/lib/savon/client.rb:36:in `call'
from test.rb:9:in `<main>'

最佳答案

依赖项中的 wasabi gem 在没有 httpclient gem 的情况下似乎有问题。如果 savon 的版本是 2.3.3,安装 gem httpclient.. 它不在依赖项中,但它可能应该是。

关于Ruby Savon 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18743570/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com