mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
d268bf305e
Conditional Expressions. * lib/wsdl/soap/definitions.rb: refactoring - Move Method. * test/xsd/{test_noencoding.rb,noencoding.xml}: new files. test for encoding unspecified XML file parsing. * test/wsdl/{test_fault.rb,map,datetime}: new files. test of SOAPFault, dateTime and Apache's Map. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
37 lines
1,000 B
Ruby
37 lines
1,000 B
Ruby
require 'test/unit'
|
|
require 'soap/processor'
|
|
require 'soap/mapping'
|
|
require 'soap/rpc/element'
|
|
require 'wsdl/importer'
|
|
|
|
|
|
module WSDL
|
|
|
|
|
|
class TestMap < Test::Unit::TestCase
|
|
def setup
|
|
end
|
|
|
|
def test_by_wsdl
|
|
dir = File.dirname(File.expand_path(__FILE__))
|
|
wsdlfile = File.join(dir, 'map.wsdl')
|
|
xml = File.open(File.join(dir, 'map.xml')) { |f| f.read }
|
|
wsdl = WSDL::Importer.import(wsdlfile)
|
|
service = wsdl.services[0]
|
|
port = service.ports[0]
|
|
wsdl_types = wsdl.collect_complextypes
|
|
rpc_decode_typemap = wsdl_types + wsdl.soap_rpc_complextypes(port.find_binding)
|
|
opt = {}
|
|
opt[:default_encodingstyle] = ::SOAP::EncodingNamespace
|
|
opt[:decode_typemap] = rpc_decode_typemap
|
|
header, body = ::SOAP::Processor.unmarshal(xml, opt)
|
|
map = ::SOAP::Mapping.soap2obj(body.response)
|
|
assert_equal(["a1"], map["a"]["a1"])
|
|
assert_equal(["a2"], map["a"]["a2"])
|
|
assert_equal(["b1"], map["b"]["b1"])
|
|
assert_equal(["b2"], map["b"]["b2"])
|
|
end
|
|
end
|
|
|
|
|
|
end
|