/tools/Ruby/lib/ruby/1.8/soap/processor.rb

http://github.com/agross/netopenspace · Ruby · 66 lines · 44 code · 17 blank · 5 comment · 1 complexity · 65bd14e80a03752c101bbbc00fad6bfe MD5 · raw file

  1. # SOAP4R - marshal/unmarshal interface.
  2. # Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
  3. # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
  4. # redistribute it and/or modify it under the same terms of Ruby's license;
  5. # either the dual license version in 2003, or any later version.
  6. require 'xsd/datatypes'
  7. require 'soap/soap'
  8. require 'soap/element'
  9. require 'soap/parser'
  10. require 'soap/generator'
  11. require 'soap/encodingstyle/soapHandler'
  12. require 'soap/encodingstyle/literalHandler'
  13. require 'soap/encodingstyle/aspDotNetHandler'
  14. module SOAP
  15. module Processor
  16. @@default_parser_option = {}
  17. class << self
  18. public
  19. def marshal(env, opt = {}, io = nil)
  20. generator = create_generator(opt)
  21. marshalled_str = generator.generate(env, io)
  22. unless env.external_content.empty?
  23. opt[:external_content] = env.external_content
  24. end
  25. marshalled_str
  26. end
  27. def unmarshal(stream, opt = {})
  28. parser = create_parser(opt)
  29. parser.parse(stream)
  30. end
  31. def default_parser_option=(rhs)
  32. @@default_parser_option = rhs
  33. end
  34. def default_parser_option
  35. @@default_parser_option
  36. end
  37. private
  38. def create_generator(opt)
  39. SOAPGenerator.new(opt)
  40. end
  41. def create_parser(opt)
  42. if opt.empty?
  43. opt = @@default_parser_option
  44. end
  45. ::SOAP::Parser.new(opt)
  46. end
  47. end
  48. end
  49. end