Forum: Ruby SOAP and NTLM Authentication

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B28bf84126112cd09006ff678f5fda61?d=identicon&s=25 Andrew Porter (Guest)
on 2009-03-26 23:54
(Received via mailing list)
I'm trying to integrate with Sharepoint Services, and need to connect
to the server using NTLM authentication. I can't get the following
lines of code to work:

WSDL_URL = 'http://sharepoint.wavetronix.local/_vti_bin/lists....
soap = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver

I keep getting a 401, "Unauthorized" error. This code does work:

client = HTTPClient.new
client.set_auth(nil, 'DOMAIN\username', 'password')
response = client.get(WSDL_URL)

All examples I find show setting authorization properties AFTER the
create_rpc_driver call above. I need to authorize BEFORE so I can
actually access the WSDL file. How do I do this?

Andy Porter
p: (801) 319-0475 | e: partydrone@me.com
134ea397777886d6f0aa992672a50eaa?d=identicon&s=25 Mark Thomas (Guest)
on 2009-03-27 10:20
(Received via mailing list)
On Mar 26, 6:50 pm, Andrew Porter <partydr...@me.com> wrote:
>
> client = HTTPClient.new
> client.set_auth(nil, 'DOMAIN\username', 'password')
> response = client.get(WSDL_URL)
>
> All examples I find show setting authorization properties AFTER the  
> create_rpc_driver call above. I need to authorize BEFORE so I can  
> actually access the WSDL file. How do I do this?

http://markthomas.org/2007/09/12/getting-started-w...
B28bf84126112cd09006ff678f5fda61?d=identicon&s=25 Andrew Porter (Guest)
on 2009-03-27 17:07
(Received via mailing list)
The example you give on your blog, like all the others I've seen,
assumes the WSDL file is "in the open." In my case, I have to
authenticate in order to even get to it. Your example creates the
driver first, then adds authentication for subsequent requests. I
can't even create the driver. The SOAP::WSDLDriverFactory.new() call
fails every time with a 401, "Unauthorized" error.

Also, I'm using the SOAP libraries in Ruby 1.8.6. It's my
understanding that soap4r was integrated into this version of Ruby. Am
I mistaken?
104fcd49d9f843ec98e40883c2fc2a0d?d=identicon&s=25 Dan Webb (danw85)
on 2009-03-27 17:15
(Received via mailing list)
I'm not sure it'll be totally helpful. But the tutorial I wrote on
adding extra header using SOAP4R may point you in the right direction.

http://dan-webb.co.uk/wordpress/?p=13

SOAP4R was integrated in 1.8.6 but is an old and buggy version of it. So
you Hiro recommends you update it and use the newer version (1.5.8)


Cheers,
Dan
134ea397777886d6f0aa992672a50eaa?d=identicon&s=25 Mark Thomas (Guest)
on 2009-03-27 18:31
(Received via mailing list)
On Mar 27, 12:01 pm, Andrew Porter <partydr...@me.com> wrote:
> The example you give on your blog, like all the others I've seen,  
> assumes the WSDL file is "in the open." In my case, I have to  
> authenticate in order to even get to it. Your example creates the  
> driver first, then adds authentication for subsequent requests. I  
> can't even create the driver. The SOAP::WSDLDriverFactory.new() call  
> fails every time with a 401, "Unauthorized" error.

Since you have shown you can get the WSDL, can't you just use it
locally when generating your client?

wsdl2ruby --wsdl <local_filename.wsdl> --type client --force

> Also, I'm using the SOAP libraries in Ruby 1.8.6. It's my  
> understanding that soap4r was integrated into this version of Ruby. Am  
> I mistaken?

Do NOT use the built-in libraries. Please upgrade to the latest.
B28bf84126112cd09006ff678f5fda61?d=identicon&s=25 Andrew Porter (partydrone)
on 2009-03-27 18:55
The following code seems to be working:

require 'rubygems'
gem 'soap4r'
require 'defaultDriver'

user = 'DOMAIN\username'
pass = 'password'

driver = ListsSoap.new
driver.options['protocol.http.auth.ntlm'] = [nil, user, pass]
driver.wiredump_file_base = 'soap.log'

lists = driver.getListCollection(nil)


I used the wsdl2ruby utility and generated the files. I was, however,
hoping to do this dynamically…
2d8b8b3782611eae032f194a900db4ef?d=identicon&s=25 Vetrivel Vaithilingam (vetrivel)
on 2010-05-26 16:57
Andrew Porter wrote:
> The following code seems to be working:
>
> require 'rubygems'
> gem 'soap4r'
> require 'defaultDriver'
>
> user = 'DOMAIN\username'
> pass = 'password'
>
> driver = ListsSoap.new
> driver.options['protocol.http.auth.ntlm'] = [nil, user, pass]
> driver.wiredump_file_base = 'soap.log'
>
> lists = driver.getListCollection(nil)
>
>
> I used the wsdl2ruby utility and generated the files. I was, however,
> hoping to do this dynamically…


Hai ,
         I have tried this . But it is not working . For network
credential i have used this . After using also , i got Authentication
failure error from the server .
This topic is locked and can not be replied to.