From: jm Date: 2004-06-28T14:48:59+09:00 Subject: does soap have problems with structs? The following code (testsrv.rb and testclt.rb) generates /usr/local/lib/ruby/1.8/soap/mapping/registry.rb:375:in `_obj2soap': Cannot map to SOAP/OM. (SOAP::Mapping::MappingError) from /usr/local/lib/ruby/1.8/soap/mapping/registry.rb:315:in `obj2soap' from /usr/local/lib/ruby/1.8/soap/mapping/mapping.rb:105:in `_obj2soap' from /usr/local/lib/ruby/1.8/soap/mapping/mapping.rb:36:in `obj2soap' from /usr/local/lib/ruby/1.8/soap/rpc/router.rb:109:in `create_response' from /usr/local/lib/ruby/1.8/soap/rpc/router.rb:135:in `dispatch' from /usr/local/lib/ruby/1.8/soap/rpc/router.rb:61:in `route' from /usr/local/lib/ruby/1.8/soap/rpc/soaplet.rb:75:in `do_POST' from /usr/local/lib/ruby/1.8/webrick/httpservlet/abstract.rb:35:in `__send__' ... 12 levels... from /usr/local/lib/ruby/1.8/soap/mapping/mapping.rb:81:in `fault2exception' from /usr/local/lib/ruby/1.8/soap/rpc/driver.rb:195:in `call' from (eval):2:in `a_method' from ./testclt.rb:17 yet if the Structs are replaced by Hashs this works. A local call works in both cases. Is this a known problem with soap or is it something to do with my code? J. -- in testsrv.rb #!/usr/local/bin/ruby require 'webrick' require 'soap/rpc/soaplet' class Testsrv @@test_struct = Struct.new(:one,:two) def a_method @@test_struct.new("string",1) end end t = Testsrv.new() s = WEBrick::HTTPServer.new( :Port => 2000, :Logger => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG) ) srv = SOAP::RPC::SOAPlet.new() srv.add_servant(t, "urn:t") s.mount("/soap", srv) trap("INT"){s.shutdown} s.start -- in testclt.rb #!/usr/local/bin/ruby require 'soap/rpc/driver' class Testclient < SOAP::RPC::Driver @@server_default = "http://127.0.0.1:2000/soap/" @@namespace_default = "urn:t" def initialize(server=nil,namespace=nil) super(server || @@server_default, namespace || @@namespace_default) add_method("a_method") end end tc = Testclient.new() p tc.a_method