2
require 'soap/rpc/driver'
3
require 'soap/rpc/standaloneServer'
4
require 'soap/header/simplehandler'
11
class TestSimpleHandler < Test::Unit::TestCase
13
PortName = 'http://tempuri.org/authHeaderPort'
15
class PingPortServer < SOAP::RPC::StandaloneServer
22
Thread.current[:pingheader]
28
add_rpc_servant(PingService.new, PortName)
29
add_request_headerhandler(PingServerHeaderHandler)
32
class PingServerHeaderHandler < SOAP::Header::SimpleHandler
33
MyHeaderName = XSD::QName.new("http://xmlsoap.org/Ping", "PingHeader")
43
def on_simple_outbound
47
def on_simple_inbound(my_header, mu)
48
Thread.current[:pingheader] = my_header
53
class PingClientHeaderHandler < SOAP::Header::SimpleHandler
54
MyHeaderName = XSD::QName.new("http://xmlsoap.org/Ping", "PingHeader")
56
def initialize(pingHeader)
58
@pingHeader = pingHeader
59
@mustunderstand = false
62
def on_simple_outbound
63
@pingHeader # --- note, not a Hash
66
def on_simple_inbound(my_header, mustunderstand)
67
Thread.current[:pingheader] = my_header
72
@endpoint = "http://localhost:#{Port}/"
78
@server = PingPortServer.new(self.class.name, nil, '0.0.0.0', Port)
79
@server.level = Logger::Severity::ERROR
86
@client = SOAP::RPC::Driver.new(@endpoint, PortName)
87
@client.wiredump_dev = STDERR if $DEBUG
88
@client.add_method('ping')
107
h = PingClientHeaderHandler.new('pingheader')
108
@client.headerhandler << h
109
assert_equal("pingheader", @client.ping)
110
assert_equal("dummy", Thread.current[:pingheader])