I’ve spent a few days now looking on how to access a wsdl over ssl.
I’m using Ruby 1.8.6 and SOAP4R 1.5.8
In short, I need to connect to a wsdl file and also need to do the basic
authentication before SOAP::WSDLDriverFactory.new call.
So I created a soap/property file and put the correct information in
there.
I followed this link for a simple ruby program:
http://dev.ctor.org/soap4r/wiki/AccessingBasicAuthProtectedWsdl
After I set everything up, I started seeing weird errors.
So I debugged an debugged and finally I saw something funky with the
httpconfigloader.rb’s set_basic_auth method.
So I googled to see if it’s a bug or not and came upon this blog:
http://cubiclecoder.blogspot.com/2005/10/of-aggregators-laptops-ruby-and-soap.html
He talks about the same problem I am having with set_basic_auth.
But noone else seems to have this problem.
So what do I do in this case?
Do I submit this as a bug to Ruby guys?
Is this indeed a bug?
I would appreciate any responses.
Greg L. wrote:
I would appreciate any responses.
I wrote a blog post a few days ago about how to do this:
http://s2.diffuse.it/blog/show/62_Consume+SSL+protected+Web+Services+with+soap4r
maybe it is of some use to you.
I actually have looked at your blog as well when developing/debugging.
My coding strategy is pretty much the same as yours.
I’m using
client.protocol.http.ssl_config.verify_mode=OpenSSL::SSL::VERIFY_NONE
option instead of messing with the certificates.
However my problem is that the set_basic_auth function does not treat
the entries in the soap/property file correctly. Basically what happens
is client.set_basic_auth gets called three times with these values:
First time: url, nil, nil
Second time: nil, userid, nil
Third time: nil, nil, password
I find it strange that not more people are seeing this problem.
And since your code is working, I confused why mine is not.
What are your ruby and soap4r versions?
Greg L. wrote:
I actually have looked at your blog as well when developing/debugging.
cool at least i did not write that post only for me alone
However my problem is that the set_basic_auth function does not treat
the entries in the soap/property file correctly. Basically what happens
is client.set_basic_auth gets called three times with these values:
First time: url, nil, nil
Second time: nil, userid, nil
Third time: nil, nil, password
i don’t know. this did not happen to me, so i can’t help you. sorry.
I find it strange that not more people are seeing this problem.
And since your code is working, I confused why mine is not.
What are your ruby and soap4r versions?
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
soap4r (1.5.8)
OK, I was able to solve this by using the soap4r gem. All I did was
added:
gem ‘soap4r’
line to the top of my code.
Greg L. wrote:
OK, I was able to solve this by using the soap4r gem. All I did was
added:
gem ‘soap4r’
line to the top of my code.
Great. Thanks for sharing.
So I think I might have figured out what the problem is.
I looked at the soap4r’s httpconfigloader.rb and it handles
set_basic_auth different then ruby’s soap/httpconfigloader.rb. I’m
guessing the “bug” is really only in the ruby’s version.
I have the soap4r gem installed but I am not using it for some reason.
What is the difference between the ruby’s soap and soap4r? They seem
quite similar.
Am I suppose to require something to use the soap4r’s version of the
code?
Here’s my simple app, by the way:
require ‘soap/wsdlDriver’
wsdl = ‘https://server/path/to/file.wsdl’
soap = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
And here’s the soap/property file:
client.protocol.http.basic_auth.1.url = https://server/path/to/file.wsdl
client.protocol.http.basic_auth.1.userid = username
client.protocol.http.basic_auth.1.password = password
client.protocol.http.ssl_config.verify_mode=OpenSSL::SSL::VERIFY_NONE
S2 wrote:
Greg L. wrote:
OK, I was able to solve this by using the soap4r gem. All I did was
added:
gem ‘soap4r’
line to the top of my code.
Great. Thanks for sharing.
I apologize in advance for a dumb question, but in a Rails 2.3.x
environment. Where should the property file go?
And, when you say: soap/property
Is it supposed to be a file called “property” in a directory called
“soap” under “lib” ? e.g. PROJECT_ROOT/lib/soap/property ?
Galen Palmer wrote in post #942421:
And, when you say: soap/property
Is it supposed to be a file called “property” in a directory called
“soap” under “lib” ? e.g. PROJECT_ROOT/lib/soap/property ?
…just in case anyone else comes across this question:
Yes, a file called “property” in a directory called “soap” somewhere in
the ruby path or in your appplication’s directory.