sekken 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.travis.yml +11 -0
  4. data/.yardopts +6 -0
  5. data/CONTRIBUTING.md +46 -0
  6. data/Gemfile +27 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +28 -0
  9. data/Rakefile +21 -0
  10. data/donate.png +0 -0
  11. data/lib/sekken.rb +75 -0
  12. data/lib/sekken/envelope.rb +92 -0
  13. data/lib/sekken/errors.rb +9 -0
  14. data/lib/sekken/example_message.rb +41 -0
  15. data/lib/sekken/httpclient.rb +35 -0
  16. data/lib/sekken/importer.rb +77 -0
  17. data/lib/sekken/message.rb +135 -0
  18. data/lib/sekken/operation.rb +100 -0
  19. data/lib/sekken/resolver.rb +20 -0
  20. data/lib/sekken/response.rb +50 -0
  21. data/lib/sekken/version.rb +5 -0
  22. data/lib/sekken/wsdl.rb +86 -0
  23. data/lib/sekken/wsdl/binding.rb +64 -0
  24. data/lib/sekken/wsdl/binding_operation.rb +85 -0
  25. data/lib/sekken/wsdl/document.rb +83 -0
  26. data/lib/sekken/wsdl/document_collection.rb +61 -0
  27. data/lib/sekken/wsdl/input_output.rb +84 -0
  28. data/lib/sekken/wsdl/message.rb +38 -0
  29. data/lib/sekken/wsdl/operation.rb +47 -0
  30. data/lib/sekken/wsdl/port.rb +29 -0
  31. data/lib/sekken/wsdl/port_type.rb +38 -0
  32. data/lib/sekken/wsdl/port_type_operation.rb +42 -0
  33. data/lib/sekken/wsdl/service.rb +55 -0
  34. data/lib/sekken/xml/attribute.rb +13 -0
  35. data/lib/sekken/xml/element.rb +82 -0
  36. data/lib/sekken/xml/element_builder.rb +220 -0
  37. data/lib/sekken/xs/schema.rb +57 -0
  38. data/lib/sekken/xs/schema_collection.rb +49 -0
  39. data/lib/sekken/xs/types.rb +272 -0
  40. data/sekken.gemspec +42 -0
  41. data/spec/fixtures/response/another_soap_fault.xml +14 -0
  42. data/spec/fixtures/response/authentication.xml +14 -0
  43. data/spec/fixtures/response/header.xml +13 -0
  44. data/spec/fixtures/response/list.xml +18 -0
  45. data/spec/fixtures/response/multi_ref.xml +39 -0
  46. data/spec/fixtures/response/soap_fault.xml +8 -0
  47. data/spec/fixtures/response/soap_fault12.xml +18 -0
  48. data/spec/fixtures/response/taxcloud.xml +1 -0
  49. data/spec/fixtures/wsdl/amazon.wsdl +1920 -0
  50. data/spec/fixtures/wsdl/arrays_with_attributes.wsdl +117 -0
  51. data/spec/fixtures/wsdl/authentication.wsdl +63 -0
  52. data/spec/fixtures/wsdl/awse.wsdl +1510 -0
  53. data/spec/fixtures/wsdl/betfair.wsdl +2981 -0
  54. data/spec/fixtures/wsdl/blz_service.wsdl +88 -0
  55. data/spec/fixtures/wsdl/bookt/bookt.wsdl +11 -0
  56. data/spec/fixtures/wsdl/bookt/bookt0.xsd +433 -0
  57. data/spec/fixtures/wsdl/bookt/bookt1.xsd +42 -0
  58. data/spec/fixtures/wsdl/bookt/bookt10.xsd +38 -0
  59. data/spec/fixtures/wsdl/bookt/bookt11.xsd +17 -0
  60. data/spec/fixtures/wsdl/bookt/bookt12.xsd +18 -0
  61. data/spec/fixtures/wsdl/bookt/bookt13.xsd +22 -0
  62. data/spec/fixtures/wsdl/bookt/bookt14.xsd +27 -0
  63. data/spec/fixtures/wsdl/bookt/bookt15.xsd +28 -0
  64. data/spec/fixtures/wsdl/bookt/bookt2.wsdl +243 -0
  65. data/spec/fixtures/wsdl/bookt/bookt2.xsd +81 -0
  66. data/spec/fixtures/wsdl/bookt/bookt3.wsdl +286 -0
  67. data/spec/fixtures/wsdl/bookt/bookt3.xsd +61 -0
  68. data/spec/fixtures/wsdl/bookt/bookt4.xsd +35 -0
  69. data/spec/fixtures/wsdl/bookt/bookt5.xsd +22 -0
  70. data/spec/fixtures/wsdl/bookt/bookt6.xsd +26 -0
  71. data/spec/fixtures/wsdl/bookt/bookt7.xsd +18 -0
  72. data/spec/fixtures/wsdl/bookt/bookt8.xsd +22 -0
  73. data/spec/fixtures/wsdl/bookt/bookt9.xsd +29 -0
  74. data/spec/fixtures/wsdl/bronto.wsdl +3285 -0
  75. data/spec/fixtures/wsdl/bydexchange/bydexchange.wsdl +104 -0
  76. data/spec/fixtures/wsdl/bydexchange/bydexchange0.xsd +1 -0
  77. data/spec/fixtures/wsdl/bydexchange/bydexchange1.xsd +1 -0
  78. data/spec/fixtures/wsdl/bydexchange/bydexchange2.wsdl +119 -0
  79. data/spec/fixtures/wsdl/bydexchange/bydexchange2.xsd +1 -0
  80. data/spec/fixtures/wsdl/bydexchange/bydexchange3.xsd +1 -0
  81. data/spec/fixtures/wsdl/bydexchange/bydexchange4.xsd +1 -0
  82. data/spec/fixtures/wsdl/bydexchange/bydexchange5.xsd +1 -0
  83. data/spec/fixtures/wsdl/bydexchange/bydexchange6.xsd +1 -0
  84. data/spec/fixtures/wsdl/bydexchange/bydexchange7.xsd +1 -0
  85. data/spec/fixtures/wsdl/bydexchange/bydexchange8.xsd +1 -0
  86. data/spec/fixtures/wsdl/crowd.wsdl +2437 -0
  87. data/spec/fixtures/wsdl/data_exchange.wsdl +98 -0
  88. data/spec/fixtures/wsdl/document_literal_wrapped.wsdl +153 -0
  89. data/spec/fixtures/wsdl/economic.wsdl +65660 -0
  90. data/spec/fixtures/wsdl/edialog.wsdl +13148 -0
  91. data/spec/fixtures/wsdl/email_verification.wsdl +394 -0
  92. data/spec/fixtures/wsdl/equifax.wsdl +794 -0
  93. data/spec/fixtures/wsdl/geotrust.wsdl +156 -0
  94. data/spec/fixtures/wsdl/interhome.wsdl +2137 -0
  95. data/spec/fixtures/wsdl/iws.wsdl +695 -0
  96. data/spec/fixtures/wsdl/jetairways.wsdl +156 -0
  97. data/spec/fixtures/wsdl/jira.wsdl +3890 -0
  98. data/spec/fixtures/wsdl/juniper.wsdl +215 -0
  99. data/spec/fixtures/wsdl/namespaced_actions.wsdl +307 -0
  100. data/spec/fixtures/wsdl/oracle.wsdl +3629 -0
  101. data/spec/fixtures/wsdl/ratp.wsdl +955 -0
  102. data/spec/fixtures/wsdl/rio2/rio2.wsdl +74 -0
  103. data/spec/fixtures/wsdl/rio2/rio2_0.wsdl +55 -0
  104. data/spec/fixtures/wsdl/rio2/rio2_0.xsd +58 -0
  105. data/spec/fixtures/wsdl/rio2/rio2_1.xsd +41 -0
  106. data/spec/fixtures/wsdl/rio2/rio2_2.xsd +222 -0
  107. data/spec/fixtures/wsdl/rio2/rio2_3.xsd +10 -0
  108. data/spec/fixtures/wsdl/rpc_literal.wsdl +105 -0
  109. data/spec/fixtures/wsdl/spyne.wsdl +70 -0
  110. data/spec/fixtures/wsdl/stockquote.wsdl +124 -0
  111. data/spec/fixtures/wsdl/taxcloud.wsdl +934 -0
  112. data/spec/fixtures/wsdl/team_software/team_software.wsdl +542 -0
  113. data/spec/fixtures/wsdl/team_software/team_software0.xsd +448 -0
  114. data/spec/fixtures/wsdl/team_software/team_software1.xsd +41 -0
  115. data/spec/fixtures/wsdl/team_software/team_software2.xsd +258 -0
  116. data/spec/fixtures/wsdl/team_software/team_software3.xsd +14 -0
  117. data/spec/fixtures/wsdl/telefonkatalogen.wsdl +45 -0
  118. data/spec/fixtures/wsdl/temperature.wsdl +136 -0
  119. data/spec/fixtures/wsdl/wasmuth/wasmuth.wsdl +157 -0
  120. data/spec/fixtures/wsdl/wasmuth/wasmuth1.xsd +210 -0
  121. data/spec/fixtures/wsdl/wasmuth/wasmuth2.xsd +549 -0
  122. data/spec/fixtures/wsdl/xignite.wsdl +3470 -0
  123. data/spec/fixtures/wsdl/yahoo.wsdl +2425 -0
  124. data/spec/fixtures/wsdl/zanox_export_service.xml +520 -0
  125. data/spec/integration/amazon_spec.rb +51 -0
  126. data/spec/integration/authentication_spec.rb +38 -0
  127. data/spec/integration/awse_spec.rb +95 -0
  128. data/spec/integration/betfair_spec.rb +179 -0
  129. data/spec/integration/blz_service_spec.rb +46 -0
  130. data/spec/integration/bookt_spec.rb +59 -0
  131. data/spec/integration/bronto_spec.rb +178 -0
  132. data/spec/integration/bydexchange_spec.rb +40 -0
  133. data/spec/integration/crowd_spec.rb +44 -0
  134. data/spec/integration/data_exchange_spec.rb +27 -0
  135. data/spec/integration/document_literal_spec.rb +104 -0
  136. data/spec/integration/economic_spec.rb +64 -0
  137. data/spec/integration/email_verification_spec.rb +82 -0
  138. data/spec/integration/equifax_spec.rb +216 -0
  139. data/spec/integration/geotrust_spec.rb +17 -0
  140. data/spec/integration/interhome_spec.rb +156 -0
  141. data/spec/integration/iws_spec.rb +27 -0
  142. data/spec/integration/jetairways_spec.rb +142 -0
  143. data/spec/integration/jira_spec.rb +27 -0
  144. data/spec/integration/juniper_spec.rb +20 -0
  145. data/spec/integration/namespaced_actions_spec.rb +37 -0
  146. data/spec/integration/oracle_spec.rb +61 -0
  147. data/spec/integration/ratp_spec.rb +178 -0
  148. data/spec/integration/rio2_spec.rb +56 -0
  149. data/spec/integration/rpc_literal_spec.rb +101 -0
  150. data/spec/integration/spyne_spec.rb +60 -0
  151. data/spec/integration/stockquote_spec.rb +46 -0
  152. data/spec/integration/taxcloud_spec.rb +45 -0
  153. data/spec/integration/team_software_spec.rb +51 -0
  154. data/spec/integration/telefonkatalogen_spec.rb +42 -0
  155. data/spec/integration/temperature_spec.rb +71 -0
  156. data/spec/integration/wasmuth_spec.rb +47 -0
  157. data/spec/integration/xignite_spec.rb +112 -0
  158. data/spec/integration/yahoo_spec.rb +116 -0
  159. data/spec/sekken/httpclient_spec.rb +41 -0
  160. data/spec/sekken/operation/build_spec.rb +308 -0
  161. data/spec/sekken/operation/document_literal_spec.rb +53 -0
  162. data/spec/sekken/operation/example_body_spec.rb +95 -0
  163. data/spec/sekken/operation/rpc_literal_spec.rb +50 -0
  164. data/spec/sekken/operation_spec.rb +169 -0
  165. data/spec/sekken/resolver_spec.rb +38 -0
  166. data/spec/sekken/response_spec.rb +17 -0
  167. data/spec/sekken/wsdl/document_spec.rb +191 -0
  168. data/spec/sekken/wsdl_spec.rb +46 -0
  169. data/spec/sekken/xs/complex_type_spec.rb +197 -0
  170. data/spec/sekken/xs/element_spec.rb +82 -0
  171. data/spec/sekken/xs/simple_type_spec.rb +39 -0
  172. data/spec/sekken_spec.rb +128 -0
  173. data/spec/spec_helper.rb +37 -0
  174. data/spec/support/fixture.rb +19 -0
  175. data/spec/support/http_mock.rb +43 -0
  176. metadata +344 -0
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Integration with Rio II' do
4
+
5
+ before :all do
6
+ wsdl_url = 'http://193.155.1.72/MyCentral-RioII-Services/SecurityService.svc?wsdl'
7
+ wsdl0_url = 'http://193.155.1.72/MyCentral-RioII-Services/SecurityService.svc?wsdl=wsdl0'
8
+
9
+ # mock wsdl imports
10
+ http_mock.fake_request(wsdl_url, 'wsdl/rio2/rio2.wsdl')
11
+ http_mock.fake_request(wsdl0_url, 'wsdl/rio2/rio2_0.wsdl')
12
+
13
+ # mock schema imports
14
+ schema_import_base = 'http://193.155.1.72/MyCentral-RioII-Services/SecurityService.svc?xsd=xsd%d'
15
+ (0..3).each do |i|
16
+ url = schema_import_base % i
17
+ http_mock.fake_request(url, "wsdl/rio2/rio2_#{i}.xsd")
18
+ end
19
+
20
+ @client = Sekken.new(wsdl_url)
21
+ end
22
+
23
+ it 'only downloads WSDL and XML Schema imports once per location' do
24
+ expect(@client.services).to eq(
25
+ 'SecurityService' => {
26
+ ports: {
27
+ 'BasicHttpBinding_ISecurityService' => {
28
+ type: 'http://schemas.xmlsoap.org/wsdl/soap/',
29
+ location: 'http://193.155.1.72/MyCentral-RioII-Services/SecurityService.svc/soap'
30
+ }
31
+ }
32
+ }
33
+ )
34
+ end
35
+
36
+ it 'knows the GetSessionState operation' do
37
+ service, port = :SecurityService, :BasicHttpBinding_ISecurityService
38
+ operation = @client.operation(service, port, :GetSessionState)
39
+
40
+ expect(operation.input_style).to eq('document/literal')
41
+
42
+ expect(operation.example_body).to eq(
43
+ GetSessionState: {
44
+ session: {
45
+ ApplicationId: 'string',
46
+ CultureCode: 'string',
47
+ SessionId: 'string'
48
+ },
49
+ request: {
50
+ Context: 'string'
51
+ }
52
+ }
53
+ )
54
+ end
55
+
56
+ end
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Integration with an RPC/Literal example' do
4
+
5
+ subject(:client) { Sekken.new fixture('wsdl/rpc_literal') }
6
+
7
+ let(:service_name) { :SampleService }
8
+ let(:port_name) { :Sample }
9
+
10
+ it 'works with op1' do
11
+ op1 = client.operation(service_name, port_name, :op1)
12
+
13
+ # Check the example request.
14
+ expect(op1.example_body).to eq(
15
+ in: {
16
+ data1: 'int',
17
+ data2: 'int'
18
+ }
19
+ )
20
+
21
+ # Build the request. It returns a Hash without the RPC wrapper element,
22
+ # because users just don't need to care about it.
23
+ op1.body = {
24
+ in: {
25
+ data1: 24,
26
+ data2: 36
27
+ }
28
+ }
29
+
30
+ # The expected request.
31
+ expected = Nokogiri.XML('
32
+ <env:Envelope
33
+ xmlns:lol0="http://apiNamespace.com"
34
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
35
+ <env:Header/>
36
+ <env:Body>
37
+ <lol0:op1>
38
+ <in>
39
+ <data1>24</data1>
40
+ <data2>36</data2>
41
+ </in>
42
+ </lol0:op1>
43
+ </env:Body>
44
+ </env:Envelope>
45
+ ')
46
+
47
+ expect(Nokogiri.XML op1.build).
48
+ to be_equivalent_to(expected).respecting_element_order
49
+ end
50
+
51
+ it 'works with op3' do
52
+ op3 = client.operation(service_name, port_name, :op3)
53
+
54
+ # Check the example request.
55
+ expect(op3.example_body).to eq(
56
+ DataElem: {
57
+ data1: 'int',
58
+ data2: 'int'
59
+ },
60
+ in2: {
61
+ RefDataElem: 'int'
62
+ }
63
+ )
64
+
65
+ op3.body = {
66
+ DataElem: {
67
+ data1: 64,
68
+ data2: 128
69
+ },
70
+ in2: {
71
+ RefDataElem: 3
72
+ }
73
+ }
74
+
75
+ # The expected request. Notice how the RPC wrapper element 'op3' is not
76
+ # namespaced because the WSDL does not define a namespace for it.
77
+ expected = Nokogiri.XML('
78
+ <env:Envelope
79
+ xmlns:lol0="http://dataNamespace.com"
80
+ xmlns:lol1="http://refNamespace.com"
81
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
82
+ <env:Header/>
83
+ <env:Body>
84
+ <op3>
85
+ <lol0:DataElem>
86
+ <data1>64</data1>
87
+ <data2>128</data2>
88
+ </lol0:DataElem>
89
+ <in2>
90
+ <lol1:RefDataElem>3</lol1:RefDataElem>
91
+ </in2>
92
+ </op3>
93
+ </env:Body>
94
+ </env:Envelope>
95
+ ')
96
+
97
+ expect(Nokogiri.XML op3.build).
98
+ to be_equivalent_to(expected).respecting_element_order
99
+ end
100
+
101
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Integration with a Spyne.io service' do
4
+
5
+ subject(:client) { Sekken.new fixture('wsdl/spyne') }
6
+
7
+ let(:service_name) { :HelloWorldService }
8
+ let(:port_name) { :Application }
9
+
10
+ it 'returns a map of services and ports' do
11
+ expect(client.services).to eq(
12
+ 'HelloWorldService' => {
13
+ ports: {
14
+ 'Application' => {
15
+ type: 'http://schemas.xmlsoap.org/wsdl/soap/',
16
+ location: 'http://localhost:8000/'
17
+ }
18
+ }
19
+ }
20
+ )
21
+ end
22
+
23
+ it 'knows operations with attributes and attribute groups' do
24
+ operation = client.operation(service_name, port_name, 'say_hello')
25
+
26
+ expect(operation.soap_action).to eq('say_hello')
27
+ expect(operation.endpoint).to eq('http://localhost:8000/')
28
+
29
+ expect(operation.body_parts).to eq([
30
+ [['say_hello'], { namespace: 'spyne.examples.hello', form: 'qualified', singular: true }]
31
+ ])
32
+ end
33
+
34
+ it 'creates an example body with attributes' do
35
+ operation = client.operation(service_name, port_name, :say_hello)
36
+ expect(operation.example_body).to eq(say_hello: {})
37
+ end
38
+
39
+ it 'creates a request with attributes' do
40
+ operation = client.operation(service_name, port_name, :say_hello)
41
+
42
+ operation.body = { say_hello: {} }
43
+
44
+ expected = Nokogiri.XML('
45
+ <env:Envelope
46
+ xmlns:lol0="spyne.examples.hello"
47
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
48
+ <env:Header>
49
+ </env:Header>
50
+ <env:Body>
51
+ <lol0:say_hello/>
52
+ </env:Body>
53
+ </env:Envelope>
54
+ ')
55
+
56
+ expect(Nokogiri.XML operation.build).
57
+ to be_equivalent_to(expected).respecting_element_order
58
+ end
59
+
60
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Integration with Stockquote service' do
4
+
5
+ subject(:client) { Sekken.new fixture('wsdl/stockquote') }
6
+
7
+ let(:service_name) { :StockQuote }
8
+ let(:port_name) { :StockQuoteSoap }
9
+
10
+ it 'creates an example request' do
11
+ operation = client.operation(service_name, port_name, :GetQuote)
12
+
13
+ expect(operation.example_body).to eq(
14
+ GetQuote: {
15
+ symbol: 'string'
16
+ }
17
+ )
18
+ end
19
+
20
+ it 'builds a request' do
21
+ operation = client.operation(service_name, port_name, :GetQuote)
22
+
23
+ operation.body = {
24
+ GetQuote: {
25
+ symbol: 'AAPL'
26
+ }
27
+ }
28
+
29
+ expected = Nokogiri.XML(%{
30
+ <env:Envelope
31
+ xmlns:lol0="http://www.webserviceX.NET/"
32
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
33
+ <env:Header/>
34
+ <env:Body>
35
+ <lol0:GetQuote>
36
+ <lol0:symbol>AAPL</lol0:symbol>
37
+ </lol0:GetQuote>
38
+ </env:Body>
39
+ </env:Envelope>
40
+ })
41
+
42
+ expect(Nokogiri.XML operation.build).
43
+ to be_equivalent_to(expected).respecting_element_order
44
+ end
45
+
46
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Integration with Taxcloud' do
4
+
5
+ subject(:client) { Sekken.new fixture('wsdl/taxcloud') }
6
+
7
+ it 'returns a map of services and ports' do
8
+ expect(client.services).to eq(
9
+ 'TaxCloud' => {
10
+ :ports => {
11
+ 'TaxCloudSoap' => {
12
+ :type => 'http://schemas.xmlsoap.org/wsdl/soap/',
13
+ :location => 'https://api.taxcloud.net/1.0/TaxCloud.asmx'
14
+ },
15
+ 'TaxCloudSoap12' => {
16
+ :type => 'http://schemas.xmlsoap.org/wsdl/soap12/',
17
+ :location => 'https://api.taxcloud.net/1.0/TaxCloud.asmx'
18
+ }
19
+ }
20
+ }
21
+ )
22
+ end
23
+
24
+ it 'knows the operations' do
25
+ service, port = 'TaxCloud', 'TaxCloudSoap'
26
+ operation = client.operation(service, port, 'VerifyAddress')
27
+
28
+ expect(operation.soap_action).to eq('http://taxcloud.net/VerifyAddress')
29
+ expect(operation.endpoint).to eq('https://api.taxcloud.net/1.0/TaxCloud.asmx')
30
+
31
+ namespace = 'http://taxcloud.net'
32
+
33
+ expect(operation.body_parts).to eq([
34
+ [['VerifyAddress'], { namespace: namespace, form: 'qualified', singular: true }],
35
+ [['VerifyAddress', 'uspsUserID'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }],
36
+ [['VerifyAddress', 'address1'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }],
37
+ [['VerifyAddress', 'address2'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }],
38
+ [['VerifyAddress', 'city'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }],
39
+ [['VerifyAddress', 'state'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }],
40
+ [['VerifyAddress', 'zip5'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }],
41
+ [['VerifyAddress', 'zip4'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }]
42
+ ])
43
+ end
44
+
45
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Integration with TeamSoftware' do
4
+
5
+ subject(:client) { Sekken.new(wsdl_url, http_mock) }
6
+
7
+ let(:wsdl_url) { 'http://bydexchange.nbs-us.com/BYDExchangeServer.svc?wsdl' }
8
+
9
+ before do
10
+ http_mock.fake_request(wsdl_url, 'wsdl/team_software/team_software.wsdl')
11
+
12
+ # 4 schemas to import.
13
+ #
14
+ # XXX: actually some of the imported schemas import some of the other schemas,
15
+ # but it seems like we're not following those?!
16
+ schema_import_base = 'https://winteamservicestest.myteamsoftware.com/Services.svc?xsd=xsd%d'
17
+ (0..3).each do |i|
18
+ url = schema_import_base % i
19
+ http_mock.fake_request(url, "wsdl/team_software/team_software#{i}.xsd")
20
+ end
21
+ end
22
+
23
+ it 'returns a map of services and ports' do
24
+ expect(client.services).to eq(
25
+ 'ServiceManager' => {
26
+ :ports => {
27
+ 'BasicHttpBinding_IWinTeamServiceManager' => {
28
+ :type => 'http://schemas.xmlsoap.org/wsdl/soap/',
29
+ :location => 'https://winteamservicestest.myteamsoftware.com/Services.svc'
30
+ }
31
+ }
32
+ }
33
+ )
34
+ end
35
+
36
+ it 'knows the operations' do
37
+ service, port = 'ServiceManager', 'BasicHttpBinding_IWinTeamServiceManager'
38
+ operation = client.operation(service, port, 'Login')
39
+
40
+ expect(operation.soap_action).to eq('http://tempuri.org/IWinTeamServiceManager/Login')
41
+ expect(operation.endpoint).to eq('https://winteamservicestest.myteamsoftware.com/Services.svc')
42
+
43
+ namespace = 'http://tempuri.org/'
44
+
45
+ expect(operation.body_parts).to eq([
46
+ [['Login'], { namespace: namespace, form: 'qualified', singular: true }],
47
+ [['Login', 'MappingKey'], { namespace: namespace, form: 'qualified', singular: true, type: 'xs:string' }]
48
+ ])
49
+ end
50
+
51
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Integration with Telefonkatalogen' do
4
+
5
+ # reference: savon#295
6
+ subject(:client) { Sekken.new fixture('wsdl/telefonkatalogen') }
7
+
8
+ it 'returns a map of services and ports' do
9
+ expect(client.services).to eq(
10
+ 'SendSms' => {
11
+ :ports => {
12
+ 'SendSmsPort' => {
13
+ :type => 'http://schemas.xmlsoap.org/wsdl/soap/',
14
+ :location => 'http://bedrift.telefonkatalogen.no/tk/websvcsendsms.php'
15
+ }
16
+ }
17
+ }
18
+ )
19
+ end
20
+
21
+ it 'knows the operations' do
22
+ operation = client.operation('SendSms', 'SendSmsPort', 'sendsms')
23
+
24
+ expect(operation.soap_action).to eq('sendsms')
25
+
26
+ # notice how this contains 9 parts with one element each.
27
+ # it does not include the rpc wrapper.
28
+
29
+ expect(operation.body_parts).to eq([
30
+ [['sender'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }],
31
+ [['cellular'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }],
32
+ [['msg'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }],
33
+ [['smsnumgroup'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }],
34
+ [['emailaddr'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }],
35
+ [['udh'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }],
36
+ [['datetime'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }],
37
+ [['format'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }],
38
+ [['dlrurl'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }]
39
+ ])
40
+ end
41
+
42
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Integration with Temperature service' do
4
+
5
+ subject(:client) { Sekken.new fixture('wsdl/temperature') }
6
+
7
+ let(:service_name) { :ConvertTemperature }
8
+ let(:port_name) { :ConvertTemperatureSoap12 }
9
+
10
+ it 'returns an empty Hash if there are no header parts' do
11
+ operation = client.operation(service_name, port_name, :ConvertTemp)
12
+ expect(operation.example_header).to eq({})
13
+ end
14
+
15
+ it 'creates an example body' do
16
+ operation = client.operation(service_name, port_name, :ConvertTemp)
17
+
18
+ expect(operation.example_body).to eq(
19
+ ConvertTemp: {
20
+ Temperature: 'double',
21
+ FromUnit: 'string',
22
+ ToUnit: 'string'
23
+ }
24
+ )
25
+ end
26
+
27
+ it 'builds a request' do
28
+ operation = client.operation(service_name, port_name, :ConvertTemp)
29
+
30
+ # For the corrent values to pass for :from_unit and :to_unit, I searched the WSDL for
31
+ # the 'FromUnit' type which is a 'TemperatureUnit' enumeration that looks like this:
32
+ #
33
+ # <s:simpleType name='TemperatureUnit'>
34
+ # <s:restriction base='s:string'>
35
+ # <s:enumeration value='degreeCelsius'/>
36
+ # <s:enumeration value='degreeFahrenheit'/>
37
+ # <s:enumeration value='degreeRankine'/>
38
+ # <s:enumeration value='degreeReaumur'/>
39
+ # <s:enumeration value='kelvin'/>
40
+ # </s:restriction>
41
+ # </s:simpleType>
42
+ #
43
+ # TODO: somehow expose the enumeration options through the example request.
44
+ operation.body = {
45
+ ConvertTemp: {
46
+ Temperature: 30,
47
+ FromUnit: 'degreeCelsius',
48
+ ToUnit: 'degreeFahrenheit'
49
+ }
50
+ }
51
+
52
+ expected = Nokogiri.XML(%{
53
+ <env:Envelope
54
+ xmlns:lol0="http://www.webserviceX.NET/"
55
+ xmlns:env="http://www.w3.org/2003/05/soap-envelope">
56
+ <env:Header/>
57
+ <env:Body>
58
+ <lol0:ConvertTemp>
59
+ <lol0:Temperature>30</lol0:Temperature>
60
+ <lol0:FromUnit>degreeCelsius</lol0:FromUnit>
61
+ <lol0:ToUnit>degreeFahrenheit</lol0:ToUnit>
62
+ </lol0:ConvertTemp>
63
+ </env:Body>
64
+ </env:Envelope>
65
+ })
66
+
67
+ expect(Nokogiri.XML operation.build).
68
+ to be_equivalent_to(expected).respecting_element_order
69
+ end
70
+
71
+ end