SOAP WSDLDriverFactory header params

  • Thread starter steven shingler
  • Start date
S

steven shingler

[Note: parts of this message were removed to make it a legal post.]

Hi all,

I have a little bit of code which uses the WSDLDriverFactory library:
class Swrapper

def initialize(wsdl)
wsdl = SOAP::WSDLDriverFactory.new(wsdl)
@soap = wsdl.create_rpc_driver
end

def send_soap(method, params)
@soap.send("#{method}", params)
end
end

But, I can't figure out how to add stuff into the header of the soap message
- like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:bet="http://www.example.com/namespace/xsd/webservice">
<soapenv:Header>
<ticket:identity>
<ticket:id>3</bet:id>
<ticket:code>test</ticket:code>
<ticket:password>password</ticket:password>
</ticket:identity>
</soapenv:Header>
<soapenv:Body>
<ticket:title>
<ticket:summary>1</ticket:summary>
</ticket:title>
</soapenv:Body>
</soapenv:Envelope>

If anyone's used this library and knows, please shout! :)

Thanks all
Steven
 
D

Dan Webb [dbw]

Hi Steven,

Best thing to start off is get the newest version of SOAP4R from gem.
I've used the WSDL2Ruby tool. The instructions for use are up at:
http://dev.ctor.org/soap4r/wiki/Wsdl2Ruby


I'm not sure how you produce the exact header information you want but
this should help you.=20

Instead of <ticket:id>3</bet:id>=20

this code will produce something along the lines of;=20
<n1:id>3</n1:id>


soapAuthentication.rb
require 'soap/header/simplehandler'

class SoapAuthHeader < SOAP::Header::SimpleHandler
NAMESPACE =3D 'http://questionmark.com/QMWISE/'
DIGEST =3D=20
ENCODING =3D=20
SIGNATURE =3D=20

def initialize()
super(XSD::QName.new(NAMESPACE, 'Trust'))
end

def on_simple_outbound
{
"Encoding" =3D> ENCODING,
"Digest" =3D> DIGEST,
"Signature" =3D> SIGNATURE
}
=20
end
end

main.rb
require 'defaultDriver.rb'
require 'soapAuthentication.rb'
## Create QMWise SOAP Driver
wsdl =3D "http://?wsdl"
user =3D ""
pass =3D ""
obj =3D defaultSOAP.new()
obj.wiredump_dev =3D STDERR if $DEBUG

trust =3D SoapAuthHeader.new
obj.headerhandler << trust


hope this helps a little. There's very little documentation when it
comes to SOAP4R, so if you find out how to change the "n1" tag to
"ticket" can you let me know ;)

Cheers,
Dan

-----Original Message-----
From: steven shingler [mailto:[email protected]]=20
Sent: 09 February 2009 17:33
To: ruby-talk ML
Subject: SOAP WSDLDriverFactory header params

Hi all,

I have a little bit of code which uses the WSDLDriverFactory library:
class Swrapper

def initialize(wsdl)
wsdl =3D SOAP::WSDLDriverFactory.new(wsdl)
@soap =3D wsdl.create_rpc_driver
end

def send_soap(method, params)
@soap.send("#{method}", params)
end
end

But, I can't figure out how to add stuff into the header of the soap
message
- like this:

<soapenv:Envelope
xmlns:soapenv=3D"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:bet=3D"http://www.example.com/namespace/xsd/webservice">
<soapenv:Header>
<ticket:identity>
<ticket:id>3</bet:id>
<ticket:code>test</ticket:code>
<ticket:password>password</ticket:password>
</ticket:identity>
</soapenv:Header>
<soapenv:Body>
<ticket:title>
<ticket:summary>1</ticket:summary>
</ticket:title>
</soapenv:Body>
</soapenv:Envelope>

If anyone's used this library and knows, please shout! :)

Thanks all
Steven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top