Forum: Ruby SOAP WSDLDriverFactory header params

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1cb5d53d5bbf3e3afa7960ef55c240e4?d=identicon&s=25 Steven Shingler (sshingler)
on 2009-02-09 18:35
(Received via mailing list)
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
104fcd49d9f843ec98e40883c2fc2a0d?d=identicon&s=25 Dan Webb (danw85)
on 2009-02-10 10:38
(Received via mailing list)
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:id>3</bet:id>

this code will produce something along the lines of;
<n1:id>3</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 ;)

Cheers,
Dan
This topic is locked and can not be replied to.