# SOAP WSDLDriverFactory header params

**URL:** <https://www.ruby-forum.com/t/soap-wsdldriverfactory-header-params/159882>\
**Category:** Ruby\
**Created:** [February 9, 2009, 6:35pm UTC](https://www.ruby-forum.com/t/soap-wsdldriverfactory-header-params/159882 "2009-02-09T18:35:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sshingler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sshingler](https://www.ruby-forum.com/u/sshingler)\
**Post date:** [February 9, 2009, 6:35pm UTC](https://www.ruby-forum.com/t/soap-wsdldriverfactory-header-params/159882/1 "2009-02-09T18:35:13Z")

</div>

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/](http://schemas.xmlsoap.org/soap/envelope/)”  
xmlns:bet=“[http://www.example.com/namespace/xsd/webservice](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! 🙂

Thanks all  
Steven

---

<div class="post-metadata">

**Author:** ![sshingler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sshingler](https://www.ruby-forum.com/u/sshingler)\
**Post date:** [February 10, 2009, 10:38am UTC](https://www.ruby-forum.com/t/soap-wsdldriverfactory-header-params/159882/2 "2009-02-10T10:38:31Z")

</div>

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](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/](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 😉

Cheers,  
Dan
