Sha256: d98c81e7caafdac85dd2d0df0b010d7ea38424aa27ba573d15c25b3bc3c8631c

Contents?: true

Size: 932 Bytes

Versions: 7

Compression:

Stored size: 932 Bytes

Contents

require 'soap/rpc/driver'
require 'soap/header/simplehandler'

server = ARGV.shift || 'http://localhost:7000/'

class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
  MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")

  attr_accessor :sessionid

  def initialize
    super(MyHeaderName)
    @sessionid = nil
  end

  def on_simple_outbound
    if @sessionid
      { "sessionid" => @sessionid }
    end
  end

  def on_simple_inbound(my_header, mustunderstand)
    @sessionid = my_header["sessionid"]
  end
end

ns = 'http://tempuri.org/authHeaderPort'
serv = SOAP::RPC::Driver.new(server, ns)
serv.add_method('login', 'userid', 'passwd')
serv.add_method('deposit', 'amt')
serv.add_method('withdrawal', 'amt')

h = ClientAuthHeaderHandler.new

serv.headerhandler << h

serv.wiredump_dev = STDOUT

sessionid = serv.login('NaHi', 'passwd')
h.sessionid = sessionid
p serv.deposit(150)
p serv.withdrawal(120)

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
soap4r-spox-1.6.0 sample/soapheader/authheader/client2.rb
soap4r-ruby1.9-2.0.5 sample/soapheader/authheader/client2.rb
soap4r-ruby1.9-2.0.3 sample/soapheader/authheader/client2.rb
soap4r-ruby1.9-2.0.2 sample/soapheader/authheader/client2.rb
soap4r-ruby1.9-2.0.1 sample/soapheader/authheader/client2.rb
soap4r-ruby1.9-2.0.0 sample/soapheader/authheader/client2.rb
soap4r-ruby1.9-1.0.0 sample/soapheader/authheader/client2.rb