SOAP WSDLDriverFactory header params

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:id3</bet:id>
ticket:codetest</ticket:code>
ticket:passwordpassword</ticket:password>
</ticket:identity>
</soapenv:Header>
soapenv:Body
ticket:title
ticket:summary1</ticket:summary>
</ticket:title>
</soapenv:Body>
</soapenv:Envelope>

If anyone’s used this library and knows, please shout! :slight_smile:

Thanks all
Steven

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.

Instead of ticket:id3</bet:id>

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

soapAuthentication.rb
require ‘soap/header/simplehandler’

class SoapAuthHeader < SOAP::Header::SimpleHandler
NAMESPACE = ‘http://questionmark.com/QMWISE/
DIGEST =
ENCODING =
SIGNATURE =

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

def on_simple_outbound
{
“Encoding” => ENCODING,
“Digest” => DIGEST,
“Signature” => SIGNATURE
}

end
end

main.rb
require ‘defaultDriver.rb’
require ‘soapAuthentication.rb’

Create QMWise SOAP Driver

wsdl = “http://?wsdl”
user = “”
pass = “”
obj = defaultSOAP.new()
obj.wiredump_dev = STDERR if $DEBUG

trust = 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 :wink:

Cheers,
Dan