lolsoap 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +4 -0
- data/lib/lolsoap/builder.rb +15 -1
- data/lib/lolsoap/version.rb +1 -1
- data/lib/lolsoap/wsdl.rb +1 -1
- data/lib/lolsoap/wsdl_parser.rb +69 -19
- data/test/fixtures/stock_quote.wsdl +2 -1
- data/test/integration/test_envelope.rb +1 -1
- data/test/unit/test_builder.rb +1 -0
- data/test/unit/test_wsdl_parser.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3f35de62b3329ac274dbf69b5fd25052d22d41c
|
4
|
+
data.tar.gz: 306b20946e12d19ead01e087aebc890f28578f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65b2031d1b4ae9caa69bc9dadbe75a13b4d5b4adc48e0543db7959b0bcdf68c462e6e7e25d98242ba7edf27a946f833700a121888184e8bd9b74a3d55008d8b7
|
7
|
+
data.tar.gz: a1406021f4af3844a990c1b5085693bef493a02da5c326859cc8c612dfebe889f820f01478da73786e0383a6b5f703dfbe08ea55c9385b20242790477fe5bb6d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
data/lib/lolsoap/builder.rb
CHANGED
@@ -68,7 +68,21 @@ module LolSoap
|
|
68
68
|
sub_node = @node.document.create_element(name.to_s, *args)
|
69
69
|
sub_node.namespace = @node.namespace_scopes.find { |n| n.prefix == prefix }
|
70
70
|
|
71
|
-
|
71
|
+
# Nokogiri doesn't currently allow to add a child element without a
|
72
|
+
# namespace to a parent with a namespace: the child inherits the parent's
|
73
|
+
# namespace. It's a known issue:
|
74
|
+
# https://github.com/sparklemotion/nokogiri/issues/1469 Until it's fixed,
|
75
|
+
# we'll use this workaround: store the parent's namespace, set it to nil
|
76
|
+
# temporarily, add the child and re-add the original namespace to the
|
77
|
+
# parent.
|
78
|
+
if sub_node.namespace.nil?
|
79
|
+
parent_namespace = @node.namespace
|
80
|
+
@node.namespace = nil
|
81
|
+
@node << sub_node
|
82
|
+
@node.namespace = parent_namespace
|
83
|
+
else
|
84
|
+
@node << sub_node
|
85
|
+
end
|
72
86
|
|
73
87
|
builder = __class__.new(sub_node, sub_type)
|
74
88
|
yield builder if block_given?
|
data/lib/lolsoap/version.rb
CHANGED
data/lib/lolsoap/wsdl.rb
CHANGED
data/lib/lolsoap/wsdl_parser.rb
CHANGED
@@ -6,25 +6,55 @@ module LolSoap
|
|
6
6
|
class WSDLParser
|
7
7
|
class ParseError < StandardError; end
|
8
8
|
|
9
|
+
class Schema < Struct.new(:target_namespace, :element_form_default)
|
10
|
+
UNQUALIFIED = 'unqualified'
|
11
|
+
|
12
|
+
def self.from_node(node)
|
13
|
+
new(
|
14
|
+
node.attr('targetNamespace').to_s,
|
15
|
+
node.attr('elementFormDefault')
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_form
|
20
|
+
element_form_default || UNQUALIFIED
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
9
24
|
class Node
|
10
|
-
attr_reader :parser, :node, :
|
25
|
+
attr_reader :parser, :node, :schema, :name, :namespace
|
11
26
|
|
12
|
-
def initialize(parser,
|
13
|
-
@parser
|
14
|
-
@node
|
15
|
-
@
|
16
|
-
@namespace, @name = parser.namespace_and_name(node, node.attr('name').to_s, target_namespace)
|
27
|
+
def initialize(parser, schema, node)
|
28
|
+
@parser = parser
|
29
|
+
@node = node
|
30
|
+
@schema = schema
|
17
31
|
end
|
18
32
|
|
19
33
|
def id
|
20
34
|
[namespace, name]
|
21
35
|
end
|
36
|
+
|
37
|
+
def target_namespace
|
38
|
+
schema.target_namespace
|
39
|
+
end
|
22
40
|
end
|
23
41
|
|
24
42
|
class Element < Node
|
43
|
+
QUALIFIED = 'qualified'
|
44
|
+
|
45
|
+
attr_reader :form
|
46
|
+
|
47
|
+
def initialize(*params)
|
48
|
+
super(*params)
|
49
|
+
|
50
|
+
@form = node.attr('form') || schema.default_form
|
51
|
+
|
52
|
+
@namespace, @name = parser.namespace_and_name(node, node.attr('name').to_s, default_namespace)
|
53
|
+
end
|
54
|
+
|
25
55
|
def type
|
26
56
|
if complex_type = node.at_xpath('xs:complexType', parser.ns)
|
27
|
-
type = Type.new(parser,
|
57
|
+
type = Type.new(parser, schema, complex_type)
|
28
58
|
{
|
29
59
|
:elements => type.elements,
|
30
60
|
:namespace => type.namespace,
|
@@ -39,6 +69,14 @@ module LolSoap
|
|
39
69
|
max_occurs.empty? || max_occurs == '1'
|
40
70
|
end
|
41
71
|
|
72
|
+
def qualified?
|
73
|
+
form == QUALIFIED
|
74
|
+
end
|
75
|
+
|
76
|
+
def default_namespace
|
77
|
+
target_namespace
|
78
|
+
end
|
79
|
+
|
42
80
|
private
|
43
81
|
|
44
82
|
def max_occurs
|
@@ -72,6 +110,12 @@ module LolSoap
|
|
72
110
|
end
|
73
111
|
|
74
112
|
class Type < Node
|
113
|
+
def initialize(*params)
|
114
|
+
super(*params)
|
115
|
+
|
116
|
+
@namespace, @name = parser.namespace_and_name(node, node.attr('name').to_s, target_namespace)
|
117
|
+
end
|
118
|
+
|
75
119
|
def elements
|
76
120
|
parent_elements.merge(own_elements)
|
77
121
|
end
|
@@ -108,7 +152,8 @@ module LolSoap
|
|
108
152
|
|
109
153
|
def element_nodes
|
110
154
|
node.xpath('*/xs:element | */*/xs:element | xs:complexContent/xs:extension/*/xs:element | xs:complexContent/xs:extension/*/*/xs:element', parser.ns).map { |el|
|
111
|
-
element =
|
155
|
+
element = TypeElement.new(parser, schema, el)
|
156
|
+
|
112
157
|
if reference = el.attribute('ref')
|
113
158
|
ReferencedElement.new(element, parser.element(*parser.namespace_and_name(el, reference.to_s)))
|
114
159
|
else
|
@@ -140,6 +185,12 @@ module LolSoap
|
|
140
185
|
end
|
141
186
|
end
|
142
187
|
|
188
|
+
class TypeElement < Element
|
189
|
+
def default_namespace
|
190
|
+
target_namespace if qualified?
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
143
194
|
class AttributeGroup < Node
|
144
195
|
def attributes
|
145
196
|
own_attributes + referenced_attributes
|
@@ -254,8 +305,8 @@ module LolSoap
|
|
254
305
|
def types
|
255
306
|
@types ||= begin
|
256
307
|
types = {}
|
257
|
-
each_node('xs:complexType[not(@abstract="true")]') do |node,
|
258
|
-
type = Type.new(self,
|
308
|
+
each_node('xs:complexType[not(@abstract="true")]') do |node, schema|
|
309
|
+
type = Type.new(self, schema, node)
|
259
310
|
types[type.id] = {
|
260
311
|
:name => type.name,
|
261
312
|
:namespace => type.namespace,
|
@@ -274,8 +325,8 @@ module LolSoap
|
|
274
325
|
def elements
|
275
326
|
@elements ||= begin
|
276
327
|
elements = {}
|
277
|
-
each_node('xs:element') do |node,
|
278
|
-
element = Element.new(self,
|
328
|
+
each_node('xs:element') do |node, schema|
|
329
|
+
element = Element.new(self, schema, node)
|
279
330
|
elements[element.id] = {
|
280
331
|
:name => element.name,
|
281
332
|
:namespace => element.namespace,
|
@@ -378,11 +429,10 @@ module LolSoap
|
|
378
429
|
end
|
379
430
|
|
380
431
|
def each_node(xpath)
|
381
|
-
schemas.each do |
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
yield node, target_namespace
|
432
|
+
schemas.each do |schema_node|
|
433
|
+
schema = Schema.from_node(schema_node)
|
434
|
+
schema_node.xpath(xpath, ns).each do |node|
|
435
|
+
yield node, schema
|
386
436
|
end
|
387
437
|
end
|
388
438
|
end
|
@@ -392,8 +442,8 @@ module LolSoap
|
|
392
442
|
target = schemas if target.size == 0
|
393
443
|
|
394
444
|
if node = target.at_xpath("xs:#{selector}[@name='#{name.split(':').last}']", ns)
|
395
|
-
|
396
|
-
node_class.new(self,
|
445
|
+
schema = Schema.from_node(node.at_xpath('parent::xs:schema', ns))
|
446
|
+
node_class.new(self, schema, node)
|
397
447
|
end
|
398
448
|
end
|
399
449
|
end
|
@@ -12,7 +12,8 @@
|
|
12
12
|
<types>
|
13
13
|
<schema targetNamespace="http://example.com/stockquote.xsd"
|
14
14
|
xmlns:xsd3="http://example.com/stockquote.xsd"
|
15
|
-
xmlns="http://www.w3.org/2001/XMLSchema"
|
15
|
+
xmlns="http://www.w3.org/2001/XMLSchema"
|
16
|
+
elementFormDefault="qualified">
|
16
17
|
<attributeGroup name="BaseRequestAttributes">
|
17
18
|
<attribute name="signature" type="xs:string"/>
|
18
19
|
</attributeGroup>
|
@@ -28,7 +28,7 @@ module LolSoap
|
|
28
28
|
el.wont_equal nil
|
29
29
|
el.text.to_s.must_equal 'LOCO2'
|
30
30
|
|
31
|
-
el = doc.at_xpath('//ns0:tradePriceRequest/ns0:specialTickerSymbol/
|
31
|
+
el = doc.at_xpath('//ns0:tradePriceRequest/ns0:specialTickerSymbol/name', doc.namespaces)
|
32
32
|
el.wont_equal nil
|
33
33
|
el.text.to_s.must_equal 'LOCOLOCOLOCO'
|
34
34
|
|
data/test/unit/test_builder.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolsoap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Leighton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.6.13
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: A library for dealing with SOAP requests and responses.
|