Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/branches/1_5/lib/wsdl/soap/literalMappingRegistryCreator.rb

Revision 1979, 2.9 kB (checked in by nahi, 1 year ago)
  • when there are 2 unqualified anonymous elements which have the same name in a SOAP message, mapper cannot decode it to the correct object. introduced :is_anonymous in mapping_registry and do not search registry with anonymous element. closes #355.
Line 
1 # WSDL4R - Creating LiteralMappingRegistry code from WSDL.
2 # Copyright (C) 2000-2007  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
9 require 'wsdl/info'
10 require 'wsdl/soap/mappingRegistryCreatorSupport'
11
12
13 module WSDL
14 module SOAP
15
16
17 class LiteralMappingRegistryCreator
18   include MappingRegistryCreatorSupport
19
20   def initialize(definitions, name_creator, modulepath, defined_const)
21     @definitions = definitions
22     @name_creator = name_creator
23     @modulepath = modulepath
24     @elements = definitions.collect_elements
25     @elements.uniq!
26     @attributes = definitions.collect_attributes
27     @attributes.uniq!
28     @simpletypes = definitions.collect_simpletypes
29     @simpletypes.uniq!
30     @complextypes = definitions.collect_complextypes
31     @complextypes.uniq!
32     @varname = nil
33     @defined_const = defined_const
34   end
35
36   def dump(varname)
37     @varname = varname
38     result = ''
39     str = dump_complextype
40     unless str.empty?
41       result << "\n" unless result.empty?
42       result << str
43     end
44     str = dump_simpletype
45     unless str.empty?
46       result << "\n" unless result.empty?
47       result << str
48     end
49     str = dump_element
50     unless str.empty?
51       result << "\n" unless result.empty?
52       result << str
53     end
54     str = dump_attribute
55     unless str.empty?
56       result << "\n" unless result.empty?
57       result << str
58     end
59     result
60   end
61
62 private
63
64   def dump_element
65     @elements.collect { |ele|
66       # has the definition different from the complexType of the same name
67       next if ele.type.nil? and @complextypes[ele.name]
68       dump_with_inner {
69         if typedef = ele.local_complextype
70           dump_complextypedef(@modulepath, ele.name, typedef)
71         elsif typedef = ele.local_simpletype
72           dump_simpletypedef(@modulepath, ele.name, typedef)
73         elsif ele.type
74           if typedef = @complextypes[ele.type]
75             dump_complextypedef(@modulepath, ele.type, typedef, ele.name)
76           elsif typedef = @simpletypes[ele.type]
77             dump_simpletypedef(@modulepath, ele.type, typedef, ele.name)
78           end
79         end
80       }
81     }.compact.join("\n")
82   end
83
84   def dump_attribute
85     @attributes.collect { |attr|
86       if attr.local_simpletype
87         dump_with_inner {
88           dump_simpletypedef(@modulepath, attr.name, attr.local_simpletype)
89         }
90       end
91     }.compact.join("\n")
92   end
93
94   def dump_simpletype
95     @simpletypes.collect { |type|
96       dump_with_inner {
97         dump_simpletypedef(@modulepath, type.name, type)
98       }
99     }.compact.join("\n")
100   end
101
102   def dump_complextype
103     @complextypes.collect { |type|
104       unless type.abstract
105         dump_with_inner {
106           dump_complextypedef(@modulepath, type.name, type)
107         }
108       end
109     }.compact.join("\n")
110   end
111 end
112
113
114 end
115 end
Note: See TracBrowser for help on using the browser.