Search code examples
rubyauthenticationjrubyntlm

JRuby Savon Ntlm Authentication (Works in Ruby but fails in JRuby)


I am trying to consume a web service using ntlm authentication. The following code works in Ruby

        client = Savon.client(wsdl:"http://xxxxxxx/xxxxxxx/xxxxxx.asmx?WSDL",ntlm: ["user", "pass"]) 
        response = client.call(:does_entry_id_exist, message: {
                                  :server =>'xxxxxx',
                                  :entryID =>'xxxxxx'
                                  }).to_s

But when I try executing it in jRuby it gives me an Authentication error

Install the httpi-ntlm gem for experimental NTLM support

I have installed the gem and have included the same in my code but still it bombs out. Can anyone please help.


Solution

  • We had a similar issue, and unfortunately I'm stuck with JRuby 1.6.8. We had to drop Savon and use: pyu-ntlm-http gem with httpi-ntlm to finally get NTLM authentication to work:

    https://rubygems.org/gems/pyu-ntlm-http

    http://rubydoc.info/gems/pyu-ntlm-http/0.1.3.1/frames

    request = HTTPI::Request.new
    request.url = "http://WebserviceURL"
    request.auth.ntlm "username","password"
    request.headers["Content-Type"] = "text/xml; charset=UTF-8"
    request.headers["SOAPAction"] = "action"
    request.body = formatted_soap_body
    response = HTTPI.post(request)