Savon gem を使用して Web サービスに接続しようとしています。サービスについて私が知っていること:
- 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>'