wasabi 3.2.3 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eea806b4cc6f040479a5800f3c6d7462ec2b477c
4
- data.tar.gz: edff00a36860783bf18bd0454aaf60e6fe7970fb
3
+ metadata.gz: e1decaff87ba9c70512facbf036cb51ce14de471
4
+ data.tar.gz: fb1d53ef00af219bae14499bfb8ecc51b0924945
5
5
  SHA512:
6
- metadata.gz: 8da7e4a1e8b83047a5e0d52283bb4ec07eb9787e4c177515038efdfb430171a11b7da59588ed1a95b2f88caf7a41a1237b8f5f3e6f5f1d4688c84c4de6634d3d
7
- data.tar.gz: 138fef341e03976f62506503929dc01937d8cebb613e6df757c5be1cd04a20e1579438efb31847ab9418b308763fdb2f7cf40b5d49fe912036320c4c80311f90
6
+ metadata.gz: 24823fdbb179b5194940b4d9ee55a09a6e7086df3f983caec0cdb3f26fa559b3f8e749df2426cce84947a04a346eba097ca757da5ad6f070d215df077488db07
7
+ data.tar.gz: 8e186b92225fac1fa32c71103c2116e08fd2c613a12b4f9fbd800df241fa71950ce5c64ac05fca14c0ad2ec28e0bbce246b195c11e2a2c89aad75d6a125a28e2
@@ -1,3 +1,6 @@
1
+ # 3.3.0 (2014-05-03)
2
+ * Feature: [#44](https://github.com/savonrb/wasabi/pull/44) adds a feature to specify the HTTPI adapter you'd like to use.
3
+
1
4
  # 3.2.3 (2013-12-16)
2
5
  * Fix [#39](https://github.com/savonrb/wasabi/pull/39) fixes new regression in operation names. Huge thank you to #leoping for investigating this and issuing a pull request.
3
6
 
@@ -21,11 +21,12 @@ module Wasabi
21
21
  end
22
22
 
23
23
  # Accepts a WSDL +document+ to parse.
24
- def initialize(document = nil)
24
+ def initialize(document = nil, adapter = nil)
25
25
  self.document = document
26
+ self.adapter = adapter
26
27
  end
27
28
 
28
- attr_accessor :document, :request
29
+ attr_accessor :document, :request, :adapter
29
30
 
30
31
  attr_writer :xml
31
32
 
@@ -138,7 +139,7 @@ module Wasabi
138
139
  # Returns the raw WSDL document.
139
140
  # Can be used as a hook to extend the library.
140
141
  def xml
141
- @xml ||= Resolver.new(document, request).resolve
142
+ @xml ||= Resolver.new(document, request, adapter).resolve
142
143
  end
143
144
 
144
145
  # Parses the WSDL document and returns the <tt>Wasabi::Parser</tt>.
@@ -257,13 +257,25 @@ module Wasabi
257
257
 
258
258
  message_ns_id, message_type = nil
259
259
 
260
- # TODO: Support multiple 'part' elements in the message.
261
- message = @messages[port_message_type]
262
- port_message_part = message.element_children.find { |node| node.name == 'part' }
260
+ # When there is a parts attribute in soap:body element, we should use that value
261
+ # to look up the message part from messages array.
262
+ input_output_element = operation.element_children.find { |node| node.name == input_output }
263
+ if input_output_element
264
+ soap_body_element = input_output_element.element_children.find { |node| node.name == 'body' }
265
+ soap_body_parts = soap_body_element['parts'] if soap_body_element
266
+ end
263
267
 
264
- if port_message_part
265
- if (port_message_part_element = port_message_part.attribute('element'))
266
- message_ns_id, message_type = port_message_part_element.to_s.split(':')
268
+ message = @messages[port_message_type]
269
+ port_message_part = message.element_children.find do |node|
270
+ soap_body_parts.nil? ? (node.name == 'part') : ( node.name == 'part' && node['name'] == soap_body_parts)
271
+ end
272
+
273
+ if port_message_part && port_element = port_message_part.attribute('element')
274
+ port_message_part = port_element.to_s
275
+ if port_message_part.include?(':')
276
+ message_ns_id, message_type = port_message_part.split(':')
277
+ else
278
+ message_type = port_message_part
267
279
  end
268
280
  end
269
281
 
@@ -18,12 +18,13 @@ module Wasabi
18
18
  URL = /^http[s]?:/
19
19
  XML = /^</
20
20
 
21
- def initialize(document, request = nil)
21
+ def initialize(document, request = nil, adapter = nil)
22
22
  @document = document
23
23
  @request = request || HTTPI::Request.new
24
+ @adapter = adapter
24
25
  end
25
26
 
26
- attr_reader :document, :request
27
+ attr_reader :document, :request, :adapter
27
28
 
28
29
  def resolve
29
30
  raise ArgumentError, "Unable to resolve: #{document.inspect}" unless document
@@ -39,7 +40,7 @@ module Wasabi
39
40
 
40
41
  def load_from_remote
41
42
  request.url = document
42
- response = HTTPI.get(request)
43
+ response = HTTPI.get(request, adapter)
43
44
 
44
45
  raise HTTPError.new("Error: #{response.code}", response) if response.error?
45
46
 
@@ -1,3 +1,3 @@
1
1
  module Wasabi
2
- VERSION = "3.2.3"
2
+ VERSION = "3.3.0"
3
3
  end
@@ -0,0 +1,66 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <definitions
3
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
4
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
5
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
6
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
7
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
8
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9
+ xmlns:s="http://www.w3.org/2001/XMLSchema"
10
+ xmlns:actions="http://example.com/actions"
11
+ targetNamespace="http://example.com/topLevelNamespace">
12
+ <types>
13
+ <s:schema elementFormDefault="qualified" targetNamespace="http://example.com/actions">
14
+ <s:element name="SomeRequest">
15
+ <s:complexType>
16
+ <s:sequence>
17
+ <s:element name="status" type="s:string"/>
18
+ </s:sequence>
19
+ </s:complexType>
20
+ </s:element>
21
+ </s:schema>
22
+ </types>
23
+ <message name="SomeInput">
24
+ <part name="parameters" element="actions:SomeRequest"/>
25
+ <part name="requestBody" element="actions:SomeRequestBody"/>
26
+ </message>
27
+ <message name="SomeOutput">
28
+ <part name="parameters" element="actions:SomeResponse"/>
29
+ </message>
30
+ <portType name="ExamplePortType">
31
+ <operation name="SomeOperation">
32
+ <input message="actions:SomeInput"/>
33
+ <output message="actions:SomeOutput"/>
34
+ </operation>
35
+ <operation name="OtherOperation">
36
+ <input message="actions:SomeInput"/>
37
+ <output message="actions:SomeOutput"/>
38
+ </operation>
39
+ </portType>
40
+ <binding name="ExampleBinding" type="actions:ExamplePortType">
41
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
42
+ <operation name="SomeOperation">
43
+ <soap:operation soapAction="http://example.com/actions.SomeOperation" style="document"/>
44
+ <input>
45
+ <soap:body parts="requestBody" use="literal"/>
46
+ </input>
47
+ <output>
48
+ <soap:body use="literal"/>
49
+ </output>
50
+ </operation>
51
+ <operation name="OtherOperation">
52
+ <soap:operation soapAction="http://example.com/actions.SomeOperation" style="document"/>
53
+ <input>
54
+ <soap:body use="literal"/>
55
+ </input>
56
+ <output>
57
+ <soap:body use="literal"/>
58
+ </output>
59
+ </operation>
60
+ </binding>
61
+ <service name="ExampleService">
62
+ <port name="ExamplePort" binding="actions:ExampleBinding">
63
+ <soap:address location="http://localhost/soapservice/execute?path=%2Fbase%2Fincludes%2FTest+Soap%2FReturn+Rows"/>
64
+ </port>
65
+ </service>
66
+ </definitions>
@@ -1,59 +1,85 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <definitions
3
- xmlns="http://schemas.xmlsoap.org/wsdl/"
4
- xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
5
- xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
6
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
7
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
8
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9
- xmlns:s="http://www.w3.org/2001/XMLSchema"
10
- xmlns:article="http://example.com/article"
11
- xmlns:actions="http://example.com/actions"
12
- targetNamespace="http://example.com/actions">
13
- <types>
14
- <s:schema elementFormDefault="qualified" targetNamespace="http://example.com/actions">
15
- <s:element name="Save">
16
- <s:complexType>
17
- <s:sequence>
18
- <s:element name="article" type="article:Article"/>
19
- </s:sequence>
20
- </s:complexType>
21
- </s:element>
22
- </s:schema>
23
- <s:schema elementFormDefault="qualified" targetNamespace="http://example.com/article">
24
- <s:complexType name="Article">
25
- <s:sequence>
26
- <s:element minOccurs="0" name="Author" type="s:string"/>
27
- <s:element minOccurs="0" name="Title" type="s:string"/>
28
- </s:sequence>
29
- </s:complexType>
30
- </s:schema>
31
- </types>
32
- <message name="SaveSoapIn"/>
33
- <message name="SaveSoapOut">
34
- <part name="parameters" element="actions:SaveResponse"/>
35
- </message>
36
- <portType name="ArticleSoap">
37
- <operation name="Save">
38
- <input message="actions:SaveSoapIn"/>
39
- <output message="actions:SaveSoapOut"/>
40
- </operation>
41
- </portType>
42
- <binding name="ArticleSoap" type="actions:ArticleSoap">
43
- <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
44
- <operation name="Save">
45
- <soap:operation soapAction="http://example.com/actions.Save" style="document"/>
46
- <input>
47
- <soap:body use="literal"/>
48
- </input>
49
- <output>
50
- <soap:body use="literal"/>
51
- </output>
52
- </operation>
53
- </binding>
54
- <service name="StudyMDL">
55
- <port name="StudyMDLSoap" binding="actions:StudyMDLSoap">
56
- <soap:address location="http://example.com:1234/soap"/>
57
- </port>
58
- </service>
3
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
4
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
5
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
6
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
7
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
8
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9
+ xmlns:s="http://www.w3.org/2001/XMLSchema"
10
+ xmlns:article="http://example.com/article"
11
+ xmlns:actions="http://example.com/actions"
12
+ targetNamespace="http://example.com/actions">
13
+ <types>
14
+ <s:schema elementFormDefault="qualified" targetNamespace="http://example.com/actions">
15
+ <s:element name="Save">
16
+ <s:complexType>
17
+ <s:sequence>
18
+ <s:element name="article" type="article:Article"/>
19
+ </s:sequence>
20
+ </s:complexType>
21
+ </s:element>
22
+ <s:element name="Delete">
23
+ <s:complexType>
24
+ <s:sequence>
25
+ <s:element name="article" type="article:Article"/>
26
+ </s:sequence>
27
+ </s:complexType>
28
+ </s:element>
29
+
30
+ </s:schema>
31
+ <s:schema elementFormDefault="qualified" targetNamespace="http://example.com/article">
32
+ <s:complexType name="Article">
33
+ <s:sequence>
34
+ <s:element minOccurs="0" name="Author" type="s:string"/>
35
+ <s:element minOccurs="0" name="Title" type="s:string"/>
36
+ </s:sequence>
37
+ </s:complexType>
38
+ </s:schema>
39
+ </types>
40
+ <message name="SaveSoapIn"/>
41
+ <message name="SaveSoapOut">
42
+ <part name="parameters" element="actions:SaveResponse"/>
43
+ </message>
44
+ <message name="DeleteSoapIn"/>
45
+ <message name="DeleteSoapOut">
46
+ <part name="parameters" element="DeleteResponse"/>
47
+ </message>
48
+
49
+ <portType name="ArticleSoap">
50
+ <operation name="Save">
51
+ <input message="actions:SaveSoapIn"/>
52
+ <output message="actions:SaveSoapOut"/>
53
+ </operation>
54
+ <operation name="Delete">
55
+ <input message="DeleteSoapIn"/>
56
+ <output message="DeleteSoapOut"/>
57
+ </operation>
58
+ </portType>
59
+ <binding name="ArticleSoap" type="actions:ArticleSoap">
60
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
61
+ <operation name="Save">
62
+ <soap:operation soapAction="http://example.com/actions.Save" style="document"/>
63
+ <input>
64
+ <soap:body use="literal"/>
65
+ </input>
66
+ <output>
67
+ <soap:body use="literal"/>
68
+ </output>
69
+ </operation>
70
+ <operation name="Delete">
71
+ <soap:operation soapAction="http://example.com/actions.Delete" style="document"/>
72
+ <input>
73
+ <soap:body use="literal"/>
74
+ </input>
75
+ <output>
76
+ <soap:body use="literal"/>
77
+ </output>
78
+ </operation>
79
+ </binding>
80
+ <service name="StudyMDL">
81
+ <port name="StudyMDLSoap" binding="actions:StudyMDLSoap">
82
+ <soap:address location="http://example.com:1234/soap"/>
83
+ </port>
84
+ </service>
59
85
  </definitions>
@@ -0,0 +1,18 @@
1
+ class FakeAdapterForTest < HTTPI::Adapter::Base
2
+
3
+ register :fake_adapter_for_test
4
+
5
+ def initialize(request)
6
+ @@requests ||= []
7
+ @@requests.push request
8
+ @request = request
9
+ end
10
+
11
+ attr_reader :client
12
+
13
+ def request(method)
14
+ @@methods ||= []
15
+ @@methods.push method
16
+ HTTPI::Response.new(200, {}, 'wsdl_by_adapter')
17
+ end
18
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Parser do
4
+ context 'with: multiple_parts_in_message.wsdl' do
5
+
6
+ subject do
7
+ parser = Wasabi::Parser.new Nokogiri::XML(xml)
8
+ parser.parse
9
+ parser
10
+ end
11
+
12
+ let(:xml) { fixture(:multiple_parts_in_message).read }
13
+
14
+ context "with a parts attribute in soap:body element" do
15
+ it 'uses the part specified in parts attribute' do
16
+ request = subject.operations[:some_operation][:input]
17
+
18
+ request.should == "SomeRequestBody"
19
+ end
20
+ end
21
+
22
+ context "with no parts attribute in soap:body element" do
23
+ it 'uses the first part element in message' do
24
+ request = subject.operations[:other_operation][:input]
25
+
26
+ request.should == "SomeRequest"
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -22,5 +22,11 @@ describe Wasabi::Parser do
22
22
  it 'falls back to using the namespace ID in the port element' do
23
23
  subject.operations[:save][:namespace_identifier].should == 'actions'
24
24
  end
25
+
26
+ it 'gracefully handles port messages without a colon' do
27
+ subject.operations[:delete][:input].should == 'Delete'
28
+ subject.operations[:delete][:output].should == 'DeleteResponse'
29
+ subject.operations[:delete][:namespace_identifier].should be_nil
30
+ end
25
31
  end
26
32
  end
@@ -9,6 +9,17 @@ describe Wasabi::Resolver do
9
9
  xml.should == "wsdl"
10
10
  end
11
11
 
12
+ it "resolves remote documents with custom adapter" do
13
+ prev_logging = HTTPI.instance_variable_get(:@log)
14
+ HTTPI.log = false # Don't pollute rspec output by request logging
15
+ xml = Wasabi::Resolver.new("http://example.com?wsdl", nil, :fake_adapter_for_test).resolve
16
+ xml.should == "wsdl_by_adapter"
17
+ expect(FakeAdapterForTest.class_variable_get(:@@requests).size).to eq(1)
18
+ expect(FakeAdapterForTest.class_variable_get(:@@requests).first.url).to eq(URI.parse("http://example.com?wsdl"))
19
+ expect(FakeAdapterForTest.class_variable_get(:@@methods)).to eq([:get])
20
+ HTTPI.log = prev_logging
21
+ end
22
+
12
23
  it "resolves local documents" do
13
24
  xml = Wasabi::Resolver.new(fixture(:authentication).path).resolve
14
25
  xml.should == fixture(:authentication).read
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wasabi
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-16 00:00:00.000000000 Z
11
+ date: 2014-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpi
@@ -111,6 +111,7 @@ files:
111
111
  - spec/fixtures/lower_camel.wsdl
112
112
  - spec/fixtures/marketo.wsdl
113
113
  - spec/fixtures/multiple_namespaces.wsdl
114
+ - spec/fixtures/multiple_parts_in_message.wsdl
114
115
  - spec/fixtures/multiple_types.wsdl
115
116
  - spec/fixtures/namespaced_actions.wsdl
116
117
  - spec/fixtures/no_message_parts.wsdl
@@ -121,6 +122,7 @@ files:
121
122
  - spec/fixtures/tradetracker.wsdl
122
123
  - spec/fixtures/two_bindings.wsdl
123
124
  - spec/spec_helper.rb
125
+ - spec/support/adapter.rb
124
126
  - spec/support/fixture.rb
125
127
  - spec/support/profiling.rb
126
128
  - spec/wasabi/core_ext/string_spec.rb
@@ -141,6 +143,7 @@ files:
141
143
  - spec/wasabi/parser/juniper_spec.rb
142
144
  - spec/wasabi/parser/marketo_spec.rb
143
145
  - spec/wasabi/parser/multiple_namespaces_spec.rb
146
+ - spec/wasabi/parser/multiple_parts_in_message_spec.rb
144
147
  - spec/wasabi/parser/no_message_parts_spec.rb
145
148
  - spec/wasabi/parser/no_namespace_spec.rb
146
149
  - spec/wasabi/parser/no_target_namespace_spec.rb
@@ -169,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
172
  version: '0'
170
173
  requirements: []
171
174
  rubyforge_project: wasabi
172
- rubygems_version: 2.0.3
175
+ rubygems_version: 2.1.11
173
176
  signing_key:
174
177
  specification_version: 4
175
178
  summary: A simple WSDL parser
@@ -184,6 +187,7 @@ test_files:
184
187
  - spec/fixtures/lower_camel.wsdl
185
188
  - spec/fixtures/marketo.wsdl
186
189
  - spec/fixtures/multiple_namespaces.wsdl
190
+ - spec/fixtures/multiple_parts_in_message.wsdl
187
191
  - spec/fixtures/multiple_types.wsdl
188
192
  - spec/fixtures/namespaced_actions.wsdl
189
193
  - spec/fixtures/no_message_parts.wsdl
@@ -194,6 +198,7 @@ test_files:
194
198
  - spec/fixtures/tradetracker.wsdl
195
199
  - spec/fixtures/two_bindings.wsdl
196
200
  - spec/spec_helper.rb
201
+ - spec/support/adapter.rb
197
202
  - spec/support/fixture.rb
198
203
  - spec/support/profiling.rb
199
204
  - spec/wasabi/core_ext/string_spec.rb
@@ -214,6 +219,7 @@ test_files:
214
219
  - spec/wasabi/parser/juniper_spec.rb
215
220
  - spec/wasabi/parser/marketo_spec.rb
216
221
  - spec/wasabi/parser/multiple_namespaces_spec.rb
222
+ - spec/wasabi/parser/multiple_parts_in_message_spec.rb
217
223
  - spec/wasabi/parser/no_message_parts_spec.rb
218
224
  - spec/wasabi/parser/no_namespace_spec.rb
219
225
  - spec/wasabi/parser/no_target_namespace_spec.rb