PageRenderTime 165ms CodeModel.GetById 160ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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