SOAP + HTTP Authentication

Hey,

Just had a question. Been pulling out my hair all weekend trying to get
SOAP
to work properly in Rails and even straight on Ruby. I started with
Rails’
AWS and moved to Ruby’s internal libraries, after which I tried out
SOAP4R.

Now, my question is, does Rails or even Ruby itself support SOAP client
calls through basic HTTP Authentication? From the research I’ve done,
this
is an unsupported feature. I am however not willing to give up on this
yet
until I get some input from people who are definitely more experienced
than
myself.

If anyone has done this or knows a good article or tutorial, or even
reference in a manual (so I can RTFM) please let me know. I’ve got a
client
who is looking to do this I and I need to make for 100% certain that
this is
possible to do, as it is a critical component of the application
interface.

Thanks in advance,

~Drew

On Sun, Feb 05, 2006 at 08:58:21PM +0900, NAKAMURA, Hiroshi wrote:

soap4r supports BasicAuth. cf.`
http://dev.ctor.org/soap4r/browser/trunk/sample/soap/basicauth .
Unfortunately I don’t know how to do it with AWS client. Someone?

Well, if you have installed http-access2 it actually does basic auth.

Oliver

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Sorry for late reply.

Drew B. wrote:

Now, my question is, does Rails or even Ruby itself support SOAP client
calls through basic HTTP Authentication? From the research I’ve done,
this
is an unsupported feature. I am however not willing to give up on this
yet
until I get some input from people who are definitely more experienced
than
myself.

soap4r supports BasicAuth. cf.`
http://dev.ctor.org/soap4r/browser/trunk/sample/soap/basicauth .
Unfortunately I don’t know how to do it with AWS client. Someone?

Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFD5egrf6b33ts2dPkRAjqHAJ9a9iYzYVdZcRebAOF8Y3iw8aqWzgCfd++f
eUkMqVOOZPVPyN287k8LYfk=
=KVwZ
-----END PGP SIGNATURE-----

Yeah, I ended up discovering http-access2 a little while back. It
defintely
does work using this method. I wish there had been some more
documentation
out there pointing me in this direction. Luckily though some old posts
in
ruby-talk had allowed me the insite that Soap4r will automatically
detect if
http-access2 is installed and with the proper othions added, it will
login
to a server for you.

Thanks for the help though.

Now I just have to figure out why the soap outputted is slightly
different
between rails and a plain ruby script. The main issue I’m seeing now is
that
a particular Soap server that I’m working with is dependant on the order
that variables is passed in, rather than the names themselves.

When I script through Ruby itself, it will pass the variables properly,
when
I run this same script through a Rails front-end however, the variables
get
flipped. This means:

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

InventoryItem
@customer =‘BIELUM’

</env:Body>
</env:Envelope>

becomes:

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

@customer =‘BIELUM’
InventoryItem

</env:Body>
</env:Envelope>

I’m currently working with the provider of this service to understand
why
they’re order dependant, when the variables are different, but am unsure
why
there is a difference between the outputs of soap4r depending on how the
script is run, even though NOTHING has changed between the two. They
both
are run through the same objects created by wsdl2ruby …

Any thoughts ?

Just a quick follow up. I just noticed that it appears that Soap4r is
sorting the variable:

@@schema_element = [
[“in0”, “SOAP::SOAPString”],
[“in1”, “SOAP::SOAPString”],
[“in3”, “SOAP::SOAPString”],
[“in2”, “SOAP::SOAPString”],
]

The Soap it outputs is:

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

@customer =‘BIELUM’
in2
in3
InventoryItem

</env:Body>
</env:Envelope>

Which tells me that there is some sort of Array sorting occuring here.
Now
note, if run in just ruby, this same code becomes:

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

in3
InventoryItem
@customer =‘BIELUM’
in2

</env:Body>
</env:Envelope>

Either way, we’re seeing very strange behavior. It almost appears as if
the
array is being sorted then pushed or flipped … I’ve been looking
through
the Rails API, looking for a possible extension done to the sort array
methods, but have been unable to find one. Either way, my question now
is,
can I just turn off sorting? Can it just use the order I specify in the
@@schema_element class property ?

Thanks, I’ll also be directing this directly to the Soap4r site as well.
Hopefully someone out there, who is more experienced with this object
than
I, will be able to help out.

~Drew

On 2/17/06, Drew B. [email protected] wrote:

Thanks for the help though.
get

</env:Body>
</env:Envelope>

becomes:

<?xml version="1.0" encoding="utf-8" ?>