3

I'm attempting to connect to a web service using Savon gem. What I know about service:

  • wsdl file url ".../service.svc?wsdl"
  • login "login"
  • password "password"
  • domain "domain"

I successfully connected to the service via SoapUI. I entered wsdl url, login, password and domain in the GUI and the document looks like:

<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>

Now I'm trying to connect via Savon:

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

Which produces this error:

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>'

When I don't use domain:

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

I get different (correct?) error:

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>'
  • 1
    How does look your successful document in SoapUI? – Steffen Roller Sep 11 '13 at 15:50
  • I updated my question with more info – Juraj Kostolanský Sep 11 '13 at 17:09
  • looks like you get an 401 error -> no permission to the URL I suppose. – Steffen Roller Sep 11 '13 at 19:21
  • looks like you get an 401 error -> no access. B/C you use NTLM I presume there is some magic on the IIS/Windows on the server when you execute the SoapUI call. Are client and server part of the same domain? Or have you authenticated yourself before you call via SoapUI? It looks you have a problem with NTLM authentication not so much with the SOAP part. Unfortunately I don't have any experiences with NTLM and Savon. Any chance you can switch to HTTP Basic Authentication? – Steffen Roller Sep 11 '13 at 19:27

1 Answers1

1

wasabi gem from dependencies seems to have problem without httpclient gem. If the version of savon is 2.3.3, install gem httpclient.. its not in dependencies, but it probably should be.

duze
  • 11
  • 1