soap4r and basic_auth over ssl

38 views
Skip to first unread message

oleg.k...@gmail.com

unread,
Apr 18, 2008, 4:41:06 PM4/18/08
to soap4r, agor...@theworkinggroup.ca
Hello there,

I'm having some problems with getting basic_auth working. Here's some
stats:

Ruby 1.8.6
Soap4r 1.5.8
httpclient 2.1.2

This is the application flow:

>> s = SOAP::WSDLDriverFactory.new("https://somesite.com/Service?wsdl").create_rpc_driver
=> #<SOAP::RPC::Driver:#<SOAP::RPC::Proxy:https://somesite.com/
Service>>
>> s.options["protocol.http.basic_auth"] << ["https://somesite.com/Service?wsdl", "user", "pass"]
=> ["https://somesite.com/Service?wsdl", "user", "pass"]
>> s.wiredump_dev = STDOUT
=> #<IO:0x2e7d4>
>> s.getUser('bob')

And this is the result. Notice that authentication stuff doesn't get
sent. I'm not sure what kind of format they should be as, but it's
just not there.

Wire dump:

= Request

! CONNECT TO somesite.com:443
! CONNECTION ESTABLISHED
POST /services/EndUser HTTP/1.1
SOAPAction: ""
Content-Type: text/xml; charset=utf-8
User-Agent: SOAP4R/1.5.8 (/187, ruby 1.8.6 (2007-09-23) [i686-
darwin9.0.0])
Date: Fri, 18 Apr 2008 20:31:29 GMT
Content-Length: 468
Host: somesite.com

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:getUser xmlns:n1="http://enduser.webservice.quotemedia.com"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<userName xsi:type="xsd:string">bob</userName>
</n1:getUser>
</env:Body>
</env:Envelope>

= Response

HTTP/1.1 500 Internal Server Error
Server: Resin/2.1.14
Cache-Control: private
Set-Cookie: JSESSIONID=a8a2hMpDf-rf; path=/
Content-Type: text/xml; charset=utf-8
Connection: close
Transfer-Encoding: chunked
Date: Fri, 18 Apr 2008 20:31:29 GMT

1a5
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.generalException</faultcode>
<faultstring>bad credentials</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
0

! CONNECTION CLOSED


SOAP::FaultError: bad credentials
from #<SOAP::Mapping::Object:0x3a343fc>

Help please?

Artem

unread,
Apr 20, 2008, 10:36:38 AM4/20/08
to soap4r
Hi Oleg,

If I remember there was a discussion in this group abous this matter
(try to google int this group about 'property' to find it).
The general idea that you have to specify basic_auth credentials
before SOAP::WSDLDriverFactory object creation.
This could be done by specifying credentials in soap/property file.

client.protocol.http.basic_auth.1.url = https://your.soap.app/url
client.protocol.http.basic_auth.1.userid = xxxxxxxx
client.protocol.http.basic_auth.1.password = yyyyyyyyy

Regards,
Artem

On Apr 19, 12:41 am, "oleg.khaba...@gmail.com"

oleg.k...@gmail.com

unread,
Apr 20, 2008, 1:04:30 PM4/20/08
to soap4r
Yes, I needed to append my message. I tried the soap/property file
route as well. It does apply user/pass from what s.options.to_yaml
tells me. However it still doesn't send them over.

This is what i have in my soap/property:

client.protocol.http.ssl_config.ciphers = DEFAULT
client.protocol.http.basic_auth.1.url = https://somesite.com/Webservice
client.protocol.http.basic_auth.1.userid = username
client.protocol.http.basic_auth.1.password = password

Had to pass the ciphers option as well because WSDLDriverFactory.new
would crap out on https:// url. Hopefully that doesn't affect
basic_auth.

On Apr 20, 10:36 am, Artem <Artem.Tambovs...@gmail.com> wrote:
> Hi Oleg,
>
> If I remember there was a discussion in this group abous this matter
> (try to google int this group about 'property' to find it).
> The general idea that you have to specify basic_auth credentials
> before SOAP::WSDLDriverFactory object creation.
> This could be done by specifying credentials in soap/property file.
>
> client.protocol.http.basic_auth.1.url =https://your.soap.app/url

rekabutt

unread,
May 1, 2008, 9:52:43 AM5/1/08
to soap4r
I was having similar problems recently and got it resolved. I ended
up using the wsdl2ruby to create a driver. Then in the client file
adding the ssl and basic auth support.

obj = ServicesPortType.new(wsdl_url)
obj.options["protocol.http.ssl_config.verify_mode"] = nil
obj.options["protocol.http.basic_auth"] << [wsdl_url, username,
password]

I'm aware of the security loss in this case by turning off the ssl
verification, but it got it working for now. If you do want the ssl
to be on though, you have to do the verification. I saw some samples
for this on the soap4r site, but never worked on it myself.

I'm not sure what you are trying to connect to, but I ran into an
instance where it wouldn't connect to a php4 service, just php5. I
never investigated why that was.

Good luck.

On Apr 20, 12:04 pm, "oleg.khaba...@gmail.com"
<oleg.khaba...@gmail.com> wrote:
> Yes, I needed to append my message. I tried the soap/property file
> route as well. It does apply user/pass from what s.options.to_yaml
> tells me. However it still doesn't send them over.
>
> This is what i have in my soap/property:
>
> client.protocol.http.ssl_config.ciphers = DEFAULT
> client.protocol.http.basic_auth.1.url =https://somesite.com/Webservice

oleg.k...@gmail.com

unread,
May 4, 2008, 4:17:46 PM5/4/08
to soap4r
Thanks rekabutt,

I tried doing the "generate stuff with wsdl2ruby" route as you
suggested. Unfortunately result is exactly the same. Basic auth stuff
doesn't get sent at all.

I'm at loss here...
Reply all
Reply to author
Forward
0 new messages