Forum: Ruby Howto add automatically a soap header in soap4r?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Henning Panke (Guest)
on 2007-06-22 15:11
(Received via mailing list)
Hi all,
I must access a webservices that expect the SOAP action as a soap
header. I want to add this soap header automatically but I dont know
where to hook in.
My actual solution is to create a header and remove it after consuming.
The code looks like this:

require 'SystemDriver.rb'
require 'soap/header/simplehandler'

# define the action soap header
class ActionHandler < SOAP::Header::SimpleHandler
   HeaderName  =''...)

   def initialize(action)
     @m_action = action

   def on_simple_outbound

# create the connection / interface
endpoint_url = "http://localhost:1500"
obj = endpoint_url )

# enable debug output
obj.wiredump_dev = STDERR if $DEBUG

ns = ''

# getIdentity
# create action soap header
actionHandler = ns + '/getIdentity' )
# add action soap header
obj.headerhandler.add( actionHandler )
# do the request
emptyRequest = nil
puts 'getIdentity: ' + obj.getIdentity(emptyRequest).identityString
puts ''
# remove action soap header for reusing the connection / interface
obj.headerhandler.delete( actionHandler )
This topic is locked and can not be replied to.