soybean 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +15 -0
  4. data/Gemfile.lock +38 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.rdoc +19 -0
  7. data/Rakefile +44 -0
  8. data/VERSION +1 -0
  9. data/bin/soybean +22 -0
  10. data/bin/xsd2ruby +90 -0
  11. data/lib/soybean.rb +11 -0
  12. data/lib/soybean/actions/generate_classes.rb +33 -0
  13. data/soybean.gemspec +236 -0
  14. data/spec/soybean_spec.rb +5 -0
  15. data/spec/spec_helper.rb +12 -0
  16. data/vendor/soap4r/soap/attachment.rb +109 -0
  17. data/vendor/soap4r/soap/attrproxy.rb +35 -0
  18. data/vendor/soap4r/soap/base_data.rb +1095 -0
  19. data/vendor/soap4r/soap/element.rb +278 -0
  20. data/vendor/soap4r/soap/encodingstyle/asp_dot_net_handler.rb +208 -0
  21. data/vendor/soap4r/soap/encodingstyle/handler.rb +121 -0
  22. data/vendor/soap4r/soap/encodingstyle/literal_handler.rb +196 -0
  23. data/vendor/soap4r/soap/encodingstyle/soap_handler.rb +560 -0
  24. data/vendor/soap4r/soap/filter.rb +14 -0
  25. data/vendor/soap4r/soap/filter/filterchain.rb +52 -0
  26. data/vendor/soap4r/soap/filter/handler.rb +32 -0
  27. data/vendor/soap4r/soap/filter/streamhandler.rb +30 -0
  28. data/vendor/soap4r/soap/generator.rb +299 -0
  29. data/vendor/soap4r/soap/header/handler.rb +62 -0
  30. data/vendor/soap4r/soap/header/handlerset.rb +71 -0
  31. data/vendor/soap4r/soap/header/mappinghandler.rb +48 -0
  32. data/vendor/soap4r/soap/header/simplehandler.rb +45 -0
  33. data/vendor/soap4r/soap/httpconfigloader.rb +140 -0
  34. data/vendor/soap4r/soap/mapping.rb +13 -0
  35. data/vendor/soap4r/soap/mapping/encodedregistry.rb +539 -0
  36. data/vendor/soap4r/soap/mapping/factory.rb +389 -0
  37. data/vendor/soap4r/soap/mapping/literalregistry.rb +392 -0
  38. data/vendor/soap4r/soap/mapping/mapping.rb +577 -0
  39. data/vendor/soap4r/soap/mapping/registry.rb +296 -0
  40. data/vendor/soap4r/soap/mapping/rubytype_factory.rb +446 -0
  41. data/vendor/soap4r/soap/mapping/schemadefinition.rb +171 -0
  42. data/vendor/soap4r/soap/mapping/type_map.rb +107 -0
  43. data/vendor/soap4r/soap/mapping/wsdlencodedregistry.rb +212 -0
  44. data/vendor/soap4r/soap/mapping/wsdlliteralregistry.rb +249 -0
  45. data/vendor/soap4r/soap/marshal.rb +60 -0
  46. data/vendor/soap4r/soap/mimemessage.rb +243 -0
  47. data/vendor/soap4r/soap/nestedexception.rb +43 -0
  48. data/vendor/soap4r/soap/net_http_client.rb +242 -0
  49. data/vendor/soap4r/soap/ns.rb +39 -0
  50. data/vendor/soap4r/soap/parser.rb +253 -0
  51. data/vendor/soap4r/soap/processor.rb +67 -0
  52. data/vendor/soap4r/soap/property.rb +340 -0
  53. data/vendor/soap4r/soap/proxy.rb +15 -0
  54. data/vendor/soap4r/soap/rpc/cgistub.rb +248 -0
  55. data/vendor/soap4r/soap/rpc/driver.rb +222 -0
  56. data/vendor/soap4r/soap/rpc/element.rb +375 -0
  57. data/vendor/soap4r/soap/rpc/httpserver.rb +143 -0
  58. data/vendor/soap4r/soap/rpc/method_def.rb +69 -0
  59. data/vendor/soap4r/soap/rpc/proxy.rb +573 -0
  60. data/vendor/soap4r/soap/rpc/router.rb +663 -0
  61. data/vendor/soap4r/soap/rpc/rpc.rb +26 -0
  62. data/vendor/soap4r/soap/rpc/soaplet.rb +201 -0
  63. data/vendor/soap4r/soap/rpc/standalone_server.rb +44 -0
  64. data/vendor/soap4r/soap/soap.rb +154 -0
  65. data/vendor/soap4r/soap/stream_handler.rb +302 -0
  66. data/vendor/soap4r/soap/version.rb +9 -0
  67. data/vendor/soap4r/soap/wsdl_driver.rb +165 -0
  68. data/vendor/soap4r/wsdl/binding.rb +66 -0
  69. data/vendor/soap4r/wsdl/data.rb +65 -0
  70. data/vendor/soap4r/wsdl/definitions.rb +237 -0
  71. data/vendor/soap4r/wsdl/documentation.rb +33 -0
  72. data/vendor/soap4r/wsdl/import.rb +81 -0
  73. data/vendor/soap4r/wsdl/importer.rb +39 -0
  74. data/vendor/soap4r/wsdl/info.rb +51 -0
  75. data/vendor/soap4r/wsdl/message.rb +55 -0
  76. data/vendor/soap4r/wsdl/operation.rb +152 -0
  77. data/vendor/soap4r/wsdl/operation_binding.rb +241 -0
  78. data/vendor/soap4r/wsdl/param.rb +94 -0
  79. data/vendor/soap4r/wsdl/parser.rb +165 -0
  80. data/vendor/soap4r/wsdl/part.rb +53 -0
  81. data/vendor/soap4r/wsdl/port.rb +67 -0
  82. data/vendor/soap4r/wsdl/port_type.rb +76 -0
  83. data/vendor/soap4r/wsdl/service.rb +62 -0
  84. data/vendor/soap4r/wsdl/soap/address.rb +41 -0
  85. data/vendor/soap4r/wsdl/soap/binding.rb +50 -0
  86. data/vendor/soap4r/wsdl/soap/body.rb +59 -0
  87. data/vendor/soap4r/wsdl/soap/cgi_stub_creator.rb +93 -0
  88. data/vendor/soap4r/wsdl/soap/class_def_creator.rb +437 -0
  89. data/vendor/soap4r/wsdl/soap/class_def_creator_support.rb +241 -0
  90. data/vendor/soap4r/wsdl/soap/class_name_creator.rb +55 -0
  91. data/vendor/soap4r/wsdl/soap/client_skelton_creator.rb +107 -0
  92. data/vendor/soap4r/wsdl/soap/complex_type.rb +174 -0
  93. data/vendor/soap4r/wsdl/soap/data.rb +43 -0
  94. data/vendor/soap4r/wsdl/soap/definitions.rb +201 -0
  95. data/vendor/soap4r/wsdl/soap/driver_creator.rb +121 -0
  96. data/vendor/soap4r/wsdl/soap/element.rb +34 -0
  97. data/vendor/soap4r/wsdl/soap/encoded_mapping_registry_creator.rb +74 -0
  98. data/vendor/soap4r/wsdl/soap/fault.rb +57 -0
  99. data/vendor/soap4r/wsdl/soap/header.rb +87 -0
  100. data/vendor/soap4r/wsdl/soap/headerfault.rb +57 -0
  101. data/vendor/soap4r/wsdl/soap/literal_mapping_registry_creator.rb +116 -0
  102. data/vendor/soap4r/wsdl/soap/mapping_registry_creator.rb +59 -0
  103. data/vendor/soap4r/wsdl/soap/mapping_registry_creator_support.rb +377 -0
  104. data/vendor/soap4r/wsdl/soap/method_def_creator.rb +200 -0
  105. data/vendor/soap4r/wsdl/soap/operation.rb +113 -0
  106. data/vendor/soap4r/wsdl/soap/servant_skelton_creator.rb +92 -0
  107. data/vendor/soap4r/wsdl/soap/servlet_stub_creator.rb +105 -0
  108. data/vendor/soap4r/wsdl/soap/standalone_server_stub_creator.rb +101 -0
  109. data/vendor/soap4r/wsdl/soap/wsdl2ruby.rb +226 -0
  110. data/vendor/soap4r/wsdl/types.rb +45 -0
  111. data/vendor/soap4r/wsdl/wsdl.rb +25 -0
  112. data/vendor/soap4r/wsdl/xml_schema/all.rb +25 -0
  113. data/vendor/soap4r/wsdl/xml_schema/annotation.rb +35 -0
  114. data/vendor/soap4r/wsdl/xml_schema/any.rb +62 -0
  115. data/vendor/soap4r/wsdl/xml_schema/any_attribute.rb +49 -0
  116. data/vendor/soap4r/wsdl/xml_schema/attribute.rb +105 -0
  117. data/vendor/soap4r/wsdl/xml_schema/attribute_group.rb +69 -0
  118. data/vendor/soap4r/wsdl/xml_schema/choice.rb +59 -0
  119. data/vendor/soap4r/wsdl/xml_schema/complex_content.rb +98 -0
  120. data/vendor/soap4r/wsdl/xml_schema/complex_extension.rb +120 -0
  121. data/vendor/soap4r/wsdl/xml_schema/complex_restriction.rb +105 -0
  122. data/vendor/soap4r/wsdl/xml_schema/complex_type.rb +194 -0
  123. data/vendor/soap4r/wsdl/xml_schema/content.rb +96 -0
  124. data/vendor/soap4r/wsdl/xml_schema/data.rb +117 -0
  125. data/vendor/soap4r/wsdl/xml_schema/element.rb +154 -0
  126. data/vendor/soap4r/wsdl/xml_schema/enumeration.rb +37 -0
  127. data/vendor/soap4r/wsdl/xml_schema/fractiondigits.rb +38 -0
  128. data/vendor/soap4r/wsdl/xml_schema/group.rb +101 -0
  129. data/vendor/soap4r/wsdl/xml_schema/import.rb +54 -0
  130. data/vendor/soap4r/wsdl/xml_schema/import_handler.rb +46 -0
  131. data/vendor/soap4r/wsdl/xml_schema/importer.rb +103 -0
  132. data/vendor/soap4r/wsdl/xml_schema/include.rb +49 -0
  133. data/vendor/soap4r/wsdl/xml_schema/length.rb +38 -0
  134. data/vendor/soap4r/wsdl/xml_schema/list.rb +49 -0
  135. data/vendor/soap4r/wsdl/xml_schema/maxexclusive.rb +38 -0
  136. data/vendor/soap4r/wsdl/xml_schema/maxinclusive.rb +38 -0
  137. data/vendor/soap4r/wsdl/xml_schema/maxlength.rb +38 -0
  138. data/vendor/soap4r/wsdl/xml_schema/minexclusive.rb +38 -0
  139. data/vendor/soap4r/wsdl/xml_schema/mininclusive.rb +38 -0
  140. data/vendor/soap4r/wsdl/xml_schema/minlength.rb +38 -0
  141. data/vendor/soap4r/wsdl/xml_schema/parser.rb +168 -0
  142. data/vendor/soap4r/wsdl/xml_schema/pattern.rb +37 -0
  143. data/vendor/soap4r/wsdl/xml_schema/ref.rb +34 -0
  144. data/vendor/soap4r/wsdl/xml_schema/schema.rb +179 -0
  145. data/vendor/soap4r/wsdl/xml_schema/sequence.rb +55 -0
  146. data/vendor/soap4r/wsdl/xml_schema/simple_content.rb +70 -0
  147. data/vendor/soap4r/wsdl/xml_schema/simple_extension.rb +63 -0
  148. data/vendor/soap4r/wsdl/xml_schema/simple_restriction.rb +133 -0
  149. data/vendor/soap4r/wsdl/xml_schema/simple_type.rb +88 -0
  150. data/vendor/soap4r/wsdl/xml_schema/totaldigits.rb +38 -0
  151. data/vendor/soap4r/wsdl/xml_schema/union.rb +36 -0
  152. data/vendor/soap4r/wsdl/xml_schema/unique.rb +35 -0
  153. data/vendor/soap4r/wsdl/xml_schema/whitespace.rb +38 -0
  154. data/vendor/soap4r/wsdl/xml_schema/xsd2ruby.rb +176 -0
  155. data/vendor/soap4r/xsd/charset.rb +190 -0
  156. data/vendor/soap4r/xsd/codegen.rb +13 -0
  157. data/vendor/soap4r/xsd/codegen/classdef.rb +209 -0
  158. data/vendor/soap4r/xsd/codegen/commentdef.rb +35 -0
  159. data/vendor/soap4r/xsd/codegen/gensupport.rb +277 -0
  160. data/vendor/soap4r/xsd/codegen/methoddef.rb +71 -0
  161. data/vendor/soap4r/xsd/codegen/moduledef.rb +209 -0
  162. data/vendor/soap4r/xsd/datatypes.rb +1466 -0
  163. data/vendor/soap4r/xsd/datatypes1999.rb +21 -0
  164. data/vendor/soap4r/xsd/iconvcharset.rb +34 -0
  165. data/vendor/soap4r/xsd/mapping.rb +69 -0
  166. data/vendor/soap4r/xsd/namedelements.rb +133 -0
  167. data/vendor/soap4r/xsd/ns.rb +183 -0
  168. data/vendor/soap4r/xsd/qname.rb +80 -0
  169. data/vendor/soap4r/xsd/xmlparser.rb +77 -0
  170. data/vendor/soap4r/xsd/xmlparser/libxmlparser.rb +116 -0
  171. data/vendor/soap4r/xsd/xmlparser/parser.rb +101 -0
  172. data/vendor/soap4r/xsd/xmlparser/rexmlparser.rb +59 -0
  173. data/vendor/soap4r/xsd/xmlparser/xmlparser.rb +51 -0
  174. data/vendor/soap4r/xsd/xmlparser/xmlscanner.rb +150 -0
  175. metadata +316 -0
@@ -0,0 +1,200 @@
1
+ # encoding: ASCII-8BIT
2
+ # WSDL4R - Creating method definition from WSDL
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+
10
+ require 'wsdl/info'
11
+ require 'wsdl/soap/class_def_creator_support'
12
+ require 'soap/rpc/element'
13
+ require 'soap/rpc/method_def'
14
+
15
+
16
+ module WSDL
17
+ module SOAP
18
+
19
+
20
+ class MethodDefCreator
21
+ include ClassDefCreatorSupport
22
+
23
+ attr_reader :definitions
24
+ # TODO: should not export this kind of stateful information.
25
+ # will be rewwritten in 1.6.1
26
+ attr_reader :assigned_method
27
+
28
+ def initialize(definitions, name_creator, modulepath, defined_const)
29
+ @definitions = definitions
30
+ @name_creator = name_creator
31
+ @modulepath = modulepath
32
+ @simpletypes = @definitions.collect_simpletypes
33
+ @complextypes = @definitions.collect_complextypes
34
+ @elements = @definitions.collect_elements
35
+ @defined_const = defined_const
36
+ @assigned_method = {}
37
+ end
38
+
39
+ def dump(name)
40
+ methoddef = ""
41
+ porttype = @definitions.porttype(name)
42
+ binding = porttype.find_binding
43
+ if binding
44
+ create(binding.name).each do |mdef|
45
+ methoddef << ",\n" unless methoddef.empty?
46
+ methoddef << dump_method(mdef).chomp
47
+ end
48
+ end
49
+ methoddef
50
+ end
51
+
52
+ def create(bindingname)
53
+ binding = @definitions.binding(bindingname)
54
+ if binding
55
+ return binding.operations.collect { |op_bind|
56
+ next unless op_bind.soapoperation # not a SOAP operation binding
57
+ create_methoddef(op_bind)
58
+ }
59
+ end
60
+ nil
61
+ end
62
+
63
+ private
64
+
65
+ def create_methoddef(op_bind)
66
+ op_info = op_bind.operation_info
67
+ name = assign_method_name(op_bind)
68
+ soapaction = op_info.boundid.soapaction
69
+ qname = op_bind.soapoperation_name
70
+ mdef = ::SOAP::RPC::MethodDef.new(name, soapaction, qname)
71
+ op_info.parts.each do |part|
72
+ if op_info.style == :rpc
73
+ mapped_class, qname = rpcdefinedtype(part)
74
+ else
75
+ mapped_class, qname = documentdefinedtype(part)
76
+ end
77
+ mdef.add_parameter(part.io_type, part.name, qname, mapped_class)
78
+ end
79
+ op_info.faults.each do |name, faultinfo|
80
+ faultclass = mapped_class_name(name, @modulepath)
81
+ mdef.faults[faultclass] = faultinfo
82
+ end
83
+ mdef.style = op_info.style
84
+ mdef.inputuse = op_info.inputuse
85
+ mdef.outputuse = op_info.outputuse
86
+ mdef
87
+ end
88
+
89
+ def dump_method(mdef)
90
+ style = mdef.style
91
+ inputuse = mdef.inputuse
92
+ outputuse = mdef.outputuse
93
+ paramstr = param2str(mdef.parameters)
94
+ if paramstr.empty?
95
+ paramstr = '[]'
96
+ else
97
+ paramstr = "[ " << paramstr.split(/\r?\n/).join("\n ") << " ]"
98
+ end
99
+ definitions = <<__EOD__
100
+ #{ndq(mdef.soapaction)},
101
+ #{dq(mdef.name)},
102
+ #{paramstr},
103
+ { :request_style => #{nsym(style)}, :request_use => #{nsym(inputuse)},
104
+ :response_style => #{nsym(style)}, :response_use => #{nsym(outputuse)},
105
+ :faults => #{mdef.faults.inspect} }
106
+ __EOD__
107
+ if style == :rpc
108
+ assign_const(mdef.qname.namespace, 'Ns')
109
+ return <<__EOD__
110
+ [ #{dqname(mdef.qname)},
111
+ #{definitions}]
112
+ __EOD__
113
+ else
114
+ return <<__EOD__
115
+ [ #{definitions}]
116
+ __EOD__
117
+ end
118
+ end
119
+
120
+ def assign_method_name(op_bind)
121
+ method_name = safemethodname(op_bind.name)
122
+ i = 1 # starts from _2
123
+ while @assigned_method.value?(method_name)
124
+ i += 1
125
+ method_name = safemethodname("#{op_bind.name}_#{i}")
126
+ end
127
+ @assigned_method[op_bind.boundid] = method_name
128
+ method_name
129
+ end
130
+
131
+ def rpcdefinedtype(part)
132
+ if mapped = basetype_mapped_class(part.type)
133
+ return ['::' + mapped.name, nil]
134
+ elsif definedtype = @simpletypes[part.type]
135
+ return [nil, definedtype.name]
136
+ elsif definedtype = @elements[part.element]
137
+ return [nil, part.element]
138
+ elsif definedtype = @complextypes[part.type]
139
+ case definedtype.compoundtype
140
+ when :TYPE_STRUCT, :TYPE_EMPTY, :TYPE_ARRAY, :TYPE_SIMPLE
141
+ type = mapped_class_name(part.type, @modulepath)
142
+ return [type, part.type]
143
+ when :TYPE_MAP
144
+ return [Hash.name, part.type]
145
+ else
146
+ raise NotImplementedError.new("must not reach here: #{definedtype.compoundtype}")
147
+ end
148
+ elsif part.type == XSD::AnyTypeName
149
+ return [nil, nil]
150
+ else
151
+ raise RuntimeError.new("part: #{part.name} cannot be resolved")
152
+ end
153
+ end
154
+
155
+ def documentdefinedtype(part)
156
+ if mapped = basetype_mapped_class(part.type)
157
+ return ['::' + mapped.name, XSD::QName.new(nil, part.name)]
158
+ elsif definedtype = @simpletypes[part.type]
159
+ if definedtype.base
160
+ return ['::' + basetype_mapped_class(definedtype.base).name, XSD::QName.new(nil, part.name)]
161
+ else
162
+ raise RuntimeError.new("unsupported simpleType: #{definedtype}")
163
+ end
164
+ elsif definedtype = @elements[part.element]
165
+ return ['::SOAP::SOAPElement', part.element]
166
+ elsif definedtype = @complextypes[part.type]
167
+ return ['::SOAP::SOAPElement', part.type]
168
+ else
169
+ raise RuntimeError.new("part: #{part.name} cannot be resolved")
170
+ end
171
+ end
172
+
173
+ def param2str(params)
174
+ params.collect { |param|
175
+ mappingstr = mapping_info2str(param.mapped_class, param.qname)
176
+ "[:#{param.io_type.id2name}, #{dq(param.name)}, #{mappingstr}]"
177
+ }.join(",\n")
178
+ end
179
+
180
+ def mapping_info2str(mapped_class, qname)
181
+ if qname.nil?
182
+ "[#{ndq(mapped_class)}]"
183
+ else
184
+ "[#{ndq(mapped_class)}, #{ndq(qname.namespace)}, #{dq(qname.name)}]"
185
+ end
186
+ end
187
+
188
+ def ele2str(ele)
189
+ qualified = ele
190
+ if qualified
191
+ "true"
192
+ else
193
+ "false"
194
+ end
195
+ end
196
+ end
197
+
198
+
199
+ end
200
+ end
@@ -0,0 +1,113 @@
1
+ # encoding: ASCII-8BIT
2
+ # WSDL4R - WSDL SOAP operation definition.
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+
10
+ require 'wsdl/info'
11
+
12
+
13
+ module WSDL
14
+ module SOAP
15
+
16
+
17
+ class Operation < Info
18
+ class ParamInfo
19
+ attr_reader :style
20
+ attr_reader :op_name
21
+ attr_reader :optype_name
22
+ attr_reader :encodingstyle
23
+ attr_reader :headerparts
24
+ attr_reader :bodyparts
25
+ attr_reader :faultpart
26
+ attr_reader :soapaction
27
+
28
+ def initialize(style, use, encodingstyle, op_name, optype_name,
29
+ headerparts, bodyparts, faultpart, soapaction)
30
+ @style = style
31
+ @use = use
32
+ @encodingstyle = encodingstyle
33
+ @op_name = op_name
34
+ @optype_name = optype_name
35
+ @headerparts = headerparts
36
+ @bodyparts = bodyparts
37
+ @faultpart = faultpart
38
+ @soapaction = soapaction
39
+ end
40
+ end
41
+
42
+ attr_reader :soapaction
43
+ attr_reader :style
44
+
45
+ def initialize
46
+ super
47
+ @soapaction = nil
48
+ @style = nil
49
+ end
50
+
51
+ def parse_element(element)
52
+ nil
53
+ end
54
+
55
+ def parse_attr(attr, value)
56
+ case attr
57
+ when StyleAttrName
58
+ if ["document", "rpc"].include?(value.source)
59
+ @style = value.source.intern
60
+ else
61
+ raise Parser::AttributeConstraintError.new(
62
+ "Unexpected value #{ value }.")
63
+ end
64
+ when SOAPActionAttrName
65
+ @soapaction = value.source
66
+ else
67
+ nil
68
+ end
69
+ end
70
+
71
+ def operation_style
72
+ return @style if @style
73
+ if parent_binding.soapbinding
74
+ return parent_binding.soapbinding.style
75
+ end
76
+ nil
77
+ end
78
+
79
+ private
80
+
81
+ def parent_binding
82
+ parent.parent
83
+ end
84
+
85
+ def create_param_info(name_info, param)
86
+ op_style = operation_style()
87
+ op_use = param.soapbody_use
88
+ op_encodingstyle = param.soapbody_encodingstyle
89
+ op_name = name_info.op_name
90
+ optype_name = name_info.optype_name
91
+ soapheader = param.soapheader
92
+ headerparts = soapheader.collect { |item| item.find_part }
93
+ soapbody = param.soapbody
94
+ if soapbody.namespace
95
+ op_name = XSD::QName.new(soapbody.namespace, op_name.name)
96
+ end
97
+ if soapbody.parts
98
+ target = soapbody.parts.split(/\s+/)
99
+ bodyparts = name_info.parts.find_all { |part|
100
+ target.include?(part.name)
101
+ }
102
+ else
103
+ bodyparts = name_info.parts
104
+ end
105
+ faultpart = nil
106
+ ParamInfo.new(op_style, op_use, op_encodingstyle, op_name, optype_name,
107
+ headerparts, bodyparts, faultpart, parent.soapaction)
108
+ end
109
+ end
110
+
111
+
112
+ end
113
+ end
@@ -0,0 +1,92 @@
1
+ # encoding: ASCII-8BIT
2
+ # WSDL4R - Creating servant skelton code from WSDL.
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+
10
+ require 'wsdl/info'
11
+ require 'wsdl/soap/class_def_creator_support'
12
+ require 'xsd/codegen'
13
+
14
+
15
+ module WSDL
16
+ module SOAP
17
+
18
+
19
+ class ServantSkeltonCreator
20
+ include ClassDefCreatorSupport
21
+ include XSD::CodeGen::GenSupport
22
+
23
+ attr_reader :definitions
24
+
25
+ def initialize(definitions, name_creator, modulepath = nil)
26
+ @definitions = definitions
27
+ @name_creator = name_creator
28
+ @modulepath = modulepath
29
+ end
30
+
31
+ def dump(porttype = nil)
32
+ result = ""
33
+ if @modulepath
34
+ result << "\n"
35
+ modulepath = @modulepath.respond_to?(:lines) ? @modulepath.lines : @modulepath # RubyJedi: compatible with Ruby 1.8.6 and above
36
+ result << modulepath.collect { |ele| "module #{ele}" }.join("; ")
37
+ result << "\n\n"
38
+ end
39
+ if porttype.nil?
40
+ @definitions.porttypes.each do |porttype|
41
+ result << dump_porttype(porttype)
42
+ result << "\n"
43
+ end
44
+ else
45
+ result << dump_porttype(porttype)
46
+ end
47
+ if @modulepath
48
+ result << "\n\n"
49
+ modulepath = @modulepath.respond_to?(:lines) ? @modulepath.lines : @modulepath # RubyJedi: compatible with Ruby 1.8.6 and above
50
+ result << modulepath.collect { |ele| "end" }.join("; ")
51
+ result << "\n"
52
+ end
53
+ result
54
+ end
55
+
56
+ private
57
+
58
+ def dump_porttype(porttype)
59
+ assigned_method = collect_assigned_method(@definitions, porttype.name, @modulepath)
60
+ class_name = mapped_class_basename(porttype.name, @modulepath)
61
+ c = XSD::CodeGen::ClassDef.new(class_name)
62
+ element_definitions = @definitions.collect_elements
63
+ binding = porttype.find_binding
64
+ if binding
65
+ binding.operations.each do |op_bind|
66
+ operation = op_bind.find_operation
67
+ if operation.nil?
68
+ warn("operation not found for binding: #{op_bind}")
69
+ next
70
+ end
71
+ name = assigned_method[op_bind.boundid] || operation.name
72
+ methodname = safemethodname(name)
73
+ input = operation.input
74
+ params = input.find_message.parts.collect { |part|
75
+ safevarname(part.name)
76
+ }
77
+ m = XSD::CodeGen::MethodDef.new(methodname, params) do <<-EOD
78
+ p [#{params.join(", ")}]
79
+ raise NotImplementedError.new
80
+ EOD
81
+ end
82
+ m.comment = dump_method_signature(methodname, operation, element_definitions)
83
+ c.add_method(m)
84
+ end
85
+ end
86
+ c.dump
87
+ end
88
+ end
89
+
90
+
91
+ end
92
+ end
@@ -0,0 +1,105 @@
1
+ # encoding: ASCII-8BIT
2
+ # WSDL4R - Creating servlet stub code from WSDL.
3
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
6
+ # redistribute it and/or modify it under the same terms of Ruby's license;
7
+ # either the dual license version in 2003, or any later version.
8
+
9
+
10
+ require 'wsdl/info'
11
+ require 'wsdl/soap/mapping_registry_creator'
12
+ require 'wsdl/soap/method_def_creator'
13
+ require 'wsdl/soap/class_def_creator_support'
14
+
15
+
16
+ module WSDL
17
+ module SOAP
18
+
19
+
20
+ class ServletStubCreator
21
+ include ClassDefCreatorSupport
22
+
23
+ attr_reader :definitions
24
+
25
+ def initialize(definitions, name_creator, modulepath = nil)
26
+ @definitions = definitions
27
+ @name_creator = name_creator
28
+ @modulepath = modulepath
29
+ end
30
+
31
+ def dump(service_name)
32
+ warn("- Servlet stub can have only 1 port for now. So creating stub for the first port and rests are ignored.")
33
+ services = @definitions.service(service_name)
34
+ unless services
35
+ raise RuntimeError.new("service not defined: #{service_name}")
36
+ end
37
+ ports = services.ports
38
+ if ports.empty?
39
+ raise RuntimeError.new("ports not found for #{service_name}")
40
+ end
41
+ port = ports[0]
42
+ if port.porttype.nil?
43
+ raise RuntimeError.new("porttype not found for #{port}")
44
+ end
45
+ dump_porttype(port.porttype)
46
+ end
47
+
48
+ private
49
+
50
+ def dump_porttype(porttype)
51
+ class_name = mapped_class_name(porttype.name, @modulepath)
52
+ defined_const = {}
53
+ methoddef = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype.name)
54
+ wsdl_name = @definitions.name ? @definitions.name.name : 'default'
55
+ mrname = safeconstname(wsdl_name + 'MappingRegistry')
56
+ c1 = XSD::CodeGen::ClassDef.new(class_name)
57
+ c1.def_require("soap/rpc/soaplet")
58
+ c1.def_code <<-EOD
59
+ Methods = [
60
+ #{methoddef.gsub(/^/, " ")}
61
+ ]
62
+ EOD
63
+ defined_const.each do |ns, tag|
64
+ c1.def_const(tag, dq(ns))
65
+ end
66
+ c2 = XSD::CodeGen::ClassDef.new(class_name + "Servlet",
67
+ "::SOAP::RPC::SOAPlet")
68
+ c2.def_method("initialize", "router = nil") do
69
+ <<-EOD
70
+ super(router)
71
+ servant = #{class_name}.new
72
+ #{class_name}::Methods.each do |definitions|
73
+ opt = definitions.last
74
+ if opt[:request_style] == :document
75
+ @router.add_document_operation(servant, *definitions)
76
+ else
77
+ @router.add_rpc_operation(servant, *definitions)
78
+ end
79
+ end
80
+ @router.mapping_registry = #{mrname}::EncodedRegistry
81
+ @router.literal_mapping_registry = #{mrname}::LiteralRegistry
82
+ EOD
83
+ end
84
+ c1.dump + "\n" + c2.dump + format(<<-EOD)
85
+
86
+ if $0 == __FILE__
87
+ require 'webrick'
88
+ server = WEBrick::HTTPServer.new(
89
+ :BindAddress => "0.0.0.0",
90
+ :Port => 10080,
91
+ :DocumentRoot => "."
92
+ )
93
+ server.mount("/", #{c2.name}.new)
94
+ trap(:INT) do
95
+ server.shutdown
96
+ end
97
+ server.start
98
+ end
99
+ EOD
100
+ end
101
+ end
102
+
103
+
104
+ end
105
+ end