2
require 'soap/rpc/httpserver'
3
require 'soap/wsdlDriver'
9
class TestMap < Test::Unit::TestCase
11
DIR = File.dirname(File.expand_path(__FILE__))
13
class Server < ::SOAP::RPC::HTTPServer
15
add_method(self, 'map')
16
add_method(self, 'map2', 'arg')
35
:BindAddress => "0.0.0.0",
38
:SOAPDefaultNamespace => "urn:map"
40
@server.level = Logger::Severity::ERROR
42
Thread.current.abort_on_exception = true
48
wsdl = File.join(DIR, 'map.wsdl')
49
@client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
50
@client.endpoint_url = "http://localhost:#{Port}/"
51
@client.generate_explicit_type = true
52
@client.wiredump_dev = STDOUT if $DEBUG
71
dir = File.dirname(File.expand_path(__FILE__))
72
wsdlfile = File.join(dir, 'map.wsdl')
73
xml = File.open(File.join(dir, 'map.xml')) { |f| f.read }
74
wsdl = WSDL::Importer.import(wsdlfile)
75
service = wsdl.services[0]
76
port = service.ports[0]
77
wsdl_types = wsdl.collect_complextypes
78
rpc_decode_typemap = wsdl_types + wsdl.soap_rpc_complextypes(port.find_binding)
80
opt[:default_encodingstyle] = ::SOAP::EncodingNamespace
81
opt[:decode_typemap] = rpc_decode_typemap
82
header, body = ::SOAP::Processor.unmarshal(xml, opt)
83
map = ::SOAP::Mapping.soap2obj(body.response)
84
assert_equal(["a1"], map["a"]["a1"])
85
assert_equal(["a2"], map["a"]["a2"])
86
assert_equal(["b1"], map["b"]["b1"])
87
assert_equal(["b2"], map["b"]["b2"])
91
assert_equal({1 => "a", 2 => "b"}, @client.map)
92
assert_equal({1 => 2}, @client.map2({1 => 2}))
93
assert_equal({1 => {2 => 3}}, @client.map2({1 => {2 => 3}}))
94
assert_equal({["a", 2] => {2 => 3}}, @client.map2({["a", 2] => {2 => 3}}))