sekken 0.1.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.
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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 618f8169fb6022ee3b52de75d6900ef9cf53d5e3
4
+ data.tar.gz: 5f2125e6801af9ca196819a9cbf6dcda95821d38
5
+ SHA512:
6
+ metadata.gz: c3325dae933d2797fedfe1ca11edbd9c3e93cc8f5d1c88146132c95192bfdcc4e86d83e21cebbf8ac077f5ceba30805650fca3a9deb748fea6aed62a62db0373
7
+ data.tar.gz: 854878b073807be0b43489afa41db1d858a3e623ad681f4f4ede59b92eb9370401285abc7c3eb3045bc62f9081350e224c53967e3b619d823109a8de417eb0fd
@@ -0,0 +1,13 @@
1
+ .rvmrc
2
+ .DS_Store
3
+ doc
4
+ coverage
5
+ graph
6
+ pkg
7
+ *~
8
+ *.rbc
9
+ *.gem
10
+ .rspec
11
+ .bundle
12
+ Gemfile.lock
13
+ bin/
@@ -0,0 +1,11 @@
1
+ # https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options
2
+ language: "ruby"
3
+ script: "bundle exec rake --trace"
4
+ rvm:
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - 2.0
8
+ - jruby-19mode
9
+ - rbx
10
+ notifications:
11
+ irc: "irc.freenode.org#savon"
@@ -0,0 +1,6 @@
1
+ --markup markdown
2
+ --markup-provider redcarpet
3
+ -
4
+ CHANGELOG.md
5
+ LICENSE
6
+ lib/**/*.rb
@@ -0,0 +1,46 @@
1
+ # Contribution Guide
2
+
3
+ This page describes how to contribute changes to Sekken.
4
+
5
+ Please do not create a pull request without reading this guide first.
6
+ Make sure to read the documentation for your version at [savonrb.com](http://savonrb.com/)
7
+ and post questions to the [mailing list](https://groups.google.com/forum/#!forum/savonrb).
8
+
9
+ **Bug fixes**
10
+
11
+ If you really think you found a bug, please make sure to add as many information as possible
12
+ to the ticket. You're a developer, we are developers and you know we need tests to reproduce
13
+ problems and make sure they don't come back.
14
+
15
+ So if you can reproduce your problem in a spec, that would be awesome! If you can't, please
16
+ let us know how we could make this easier for you. Also, provide code and the WSDL of the
17
+ service your working with so others can try to come up with a spec for your problem.
18
+
19
+ After we have a failing spec, it obviously needs to be fixed. Make sure your new spec is the
20
+ only failing one under the `spec` directory. Travis only runs the "unit tests" at `spec/sekken`,
21
+ but Sekken actually has with some additional "integration/example specs" at `spec/integration`,
22
+ which you need to run locally to make sure the integration with real world services still works.
23
+
24
+ Notice that these specs are not run by Travis, because the service's are not guaranteed to work
25
+ all the time and the specs will timeout after a few seconds when the service is currently down.
26
+
27
+ Please follow this basic workflow for pull requests:
28
+
29
+ * [Fork the project](https://help.github.com/articles/fork-a-repo)
30
+ * Create a feature branch and make your bug fix
31
+ * Add tests for it!
32
+ * Update the [Changelog](https://github.com/savonrb/sekken/blob/master/CHANGELOG.md)
33
+ * [Send a pull request](https://help.github.com/articles/using-pull-requests)
34
+ * [Check that your pull request passes the build](https://travis-ci.org/savonrb/sekken/pull_requests)
35
+
36
+
37
+ **Improvements and feature requests**
38
+
39
+ If you have an idea for an improvement or a new feature, please feel free to
40
+ [create a new issue](https://github.com/savonrb/sekken/issues/new) and describe your idea
41
+ so that other people can give their insights and opinions. This is also important to avoid
42
+ duplicate work.
43
+
44
+ Pull requests and issues on GitHub are meant to be used to discuss problems and ideas,
45
+ so please make sure to participate and follow up on questions. In case noone comments
46
+ on your ticket, please keep updating the ticket with additional information.
data/Gemfile ADDED
@@ -0,0 +1,27 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ # profiling
5
+ #gem 'method_profiler', require: false
6
+ #gem 'ruby-prof', require: false # does not work on jruby!
7
+
8
+ # coverage
9
+ gem 'simplecov', require: false
10
+ gem 'coveralls', require: false
11
+
12
+ # dependencies
13
+ #gem 'rubydeps', require: false # uses c extensions
14
+
15
+ # debugging
16
+ #gem 'debugger', require: false # don't install on travis!
17
+
18
+ platform :rbx do
19
+ gem 'json'
20
+ gem 'racc'
21
+ gem 'rubysl'
22
+ gem 'rubinius-coverage'
23
+ end
24
+
25
+ group :development do
26
+ gem 'fuubar'
27
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Daniel Harrington
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # Sekken
2
+
3
+ Heavy metal SOAP client
4
+
5
+ [Documentation](http://savonrb.com) | [RDoc](http://rubydoc.info/gems/savon) |
6
+ [Mailing list](https://groups.google.com/forum/#!forum/savonrb) | [Twitter](http://twitter.com/savonrb)
7
+
8
+ [![Build Status](https://secure.travis-ci.org/savonrb/sekken.png?branch=master)](http://travis-ci.org/savonrb/sekken)
9
+ [![Gem Version](https://badge.fury.io/rb/sekken.png)](http://badge.fury.io/rb/sekken)
10
+ [![Code Climate](https://codeclimate.com/github/savonrb/sekken.png)](https://codeclimate.com/github/savonrb/sekken)
11
+ [![Coverage Status](https://coveralls.io/repos/savonrb/sekken/badge.png?branch=master)](https://coveralls.io/r/savonrb/sekken)
12
+
13
+
14
+ ## Version 3
15
+
16
+ **Status: Unstable.** Sekken is currently under development and available for testing on GitHub.
17
+ Use this version if you can handle changes and want to provide feedback.
18
+
19
+ Sekken is still in a very early stage, but [there is some documentation!](http://savonrb.com/version3/)
20
+
21
+ ## Give back
22
+
23
+ If you're using Sekken and you or your company is making money from it, then please consider
24
+ donating via [Gittip](https://www.gittip.com/rubiii/) so that I can continue to improve it.
25
+
26
+ [![donate](donate.png)](https://www.gittip.com/rubiii/)
27
+
28
+ Donate icon from the [Noun Project](http://thenounproject.com/noun/donate/#icon-No285).
@@ -0,0 +1,21 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ desc 'Generate a dependency graph'
7
+ task :graph do
8
+ system <<-BASH
9
+ rm -rf graph
10
+ mkdir graph
11
+ GRAPH=true rspec
12
+ mv rubydeps.dump graph
13
+ cd graph
14
+ rubydeps --path_filter='lib/sekken'
15
+ dot -Tsvg rubydeps.dot > rubydeps.svg
16
+ open -a 'Google Chrome' rubydeps.svg
17
+ BASH
18
+ end
19
+
20
+ task default: :spec
21
+ task test: :spec
Binary file
@@ -0,0 +1,75 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'logging'
3
+
4
+ require 'sekken/version'
5
+ require 'sekken/errors'
6
+ require 'sekken/wsdl'
7
+ require 'sekken/operation'
8
+ require 'sekken/httpclient'
9
+
10
+ class Sekken
11
+
12
+ NS_XSD = 'http://www.w3.org/2001/XMLSchema'
13
+ NS_WSDL = 'http://schemas.xmlsoap.org/wsdl/'
14
+
15
+ NS_SOAP_1_1 = 'http://schemas.xmlsoap.org/wsdl/soap/'
16
+ NS_SOAP_1_2 = 'http://schemas.xmlsoap.org/wsdl/soap12/'
17
+
18
+ # Public: Returns the HTTP adapter to use.
19
+ def self.http_adapter
20
+ @http_adapter ||= HTTPClient
21
+ end
22
+
23
+ # Public: Sets the HTTP adapter to use.
24
+ def self.http_adapter=(adapter)
25
+ @http_adapter = adapter
26
+ end
27
+
28
+ def initialize(wsdl, http = nil)
29
+ @http = http || new_http_client
30
+ @wsdl = WSDL.new(wsdl, @http)
31
+ end
32
+
33
+ # Public: Returns the Wasabi instance.
34
+ attr_reader :wsdl
35
+
36
+ # Public: Returns the HTTP adapter‘s client instance.
37
+ def http
38
+ @http.client
39
+ end
40
+
41
+ # Public: Returns the services and ports defined by the WSDL.
42
+ def services
43
+ @wsdl.services
44
+ end
45
+
46
+ # Public: Returns an Array of operations for a service and port.
47
+ def operations(service_name, port_name)
48
+ @wsdl.operations(service_name.to_s, port_name.to_s)
49
+ end
50
+
51
+ # Public: Returns an Operation by service, port and operation name.
52
+ def operation(service_name, port_name, operation_name)
53
+ operation = @wsdl.operation(service_name.to_s, port_name.to_s, operation_name.to_s)
54
+ verify_operation_style! operation
55
+
56
+ Operation.new(operation, @wsdl, @http)
57
+ end
58
+
59
+ private
60
+
61
+ # Private: Returns a new instance of the HTTP adapter to use.
62
+ def new_http_client
63
+ self.class.http_adapter.new
64
+ end
65
+
66
+ # Private: Raises if the operation style is not supported.
67
+ def verify_operation_style!(operation)
68
+ if operation.input_style == 'rpc/encoded'
69
+ raise UnsupportedStyleError,
70
+ "#{operation.name.inspect} is an #{operation.input_style.inspect} style operation.\n" \
71
+ "Currently this style is not supported."
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,92 @@
1
+ require 'builder'
2
+ require 'sekken/message'
3
+
4
+ class Sekken
5
+ class Envelope
6
+
7
+ NSID = 'lol'
8
+
9
+ def initialize(operation, header, body)
10
+ @logger = Logging.logger[self]
11
+
12
+ @operation = operation
13
+ @header = header || {}
14
+ @body = body || {}
15
+
16
+ @nsid_counter = -1
17
+ @namespaces = {}
18
+ end
19
+
20
+ def register_namespace(namespace)
21
+ @namespaces[namespace] ||= create_nsid
22
+ end
23
+
24
+ def to_s
25
+ build_envelope(build_header, build_body)
26
+ end
27
+
28
+ private
29
+
30
+ def create_nsid
31
+ @nsid_counter += 1
32
+ "#{NSID}#{@nsid_counter}"
33
+ end
34
+
35
+ def build_header
36
+ return "" if @header.empty?
37
+ Message.new(self, @operation.input.header_parts).build(@header)
38
+ end
39
+
40
+ def build_body
41
+ return "" if @body.empty?
42
+ body = Message.new(self, @operation.input.body_parts).build(@body)
43
+
44
+ if rpc_call?
45
+ build_rpc_wrapper(body)
46
+ else
47
+ body
48
+ end
49
+ end
50
+
51
+ def build_envelope(header, body)
52
+ builder = Builder::XmlMarkup.new(indent: 2)
53
+
54
+ builder.tag! :env, :Envelope, collect_namespaces do |xml|
55
+ xml.tag!(:env, :Header) { |xml| xml << header }
56
+ xml.tag!(:env, :Body) { |xml| xml << body }
57
+ end
58
+
59
+ builder.target!
60
+ end
61
+
62
+ def build_rpc_wrapper(body)
63
+ name = @operation.name
64
+ namespace = @operation.binding_operation.input_body[:namespace]
65
+ nsid = register_namespace(namespace) if namespace
66
+
67
+ tag = [nsid, name].compact.join(':')
68
+
69
+ '<%{tag}>%{body}</%{tag}>' % { tag: tag, body: body }
70
+ end
71
+
72
+ def rpc_call?
73
+ @operation.binding_operation.style == 'rpc'
74
+ end
75
+
76
+ def collect_namespaces
77
+ # registered namespaces
78
+ namespaces = @namespaces.each_with_object({}) { |(namespace, nsid), memo|
79
+ memo["xmlns:#{nsid}"] = namespace
80
+ }
81
+
82
+ # envelope namespace
83
+ namespaces['xmlns:env'] = case @operation.soap_version
84
+ when '1.1' then 'http://schemas.xmlsoap.org/soap/envelope/'
85
+ when '1.2' then 'http://www.w3.org/2003/05/soap-envelope'
86
+ end
87
+
88
+ namespaces
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,9 @@
1
+ class Sekken
2
+
3
+ # Public: Base error class.
4
+ Error = Class.new(RuntimeError)
5
+
6
+ # Public: Raised if the style of an operation is not supported.
7
+ UnsupportedStyleError = Class.new(Error)
8
+
9
+ end
@@ -0,0 +1,41 @@
1
+ class Sekken
2
+ class ExampleMessage
3
+
4
+ def self.build(parts)
5
+ memo = {}
6
+
7
+ parts.each do |element|
8
+ name = element.name.to_sym
9
+
10
+ case
11
+ when element.simple_type?
12
+ base_type_local = element.base_type.split(':').last
13
+ base_type_local = [base_type_local] unless element.singular?
14
+ memo[name] = base_type_local
15
+
16
+ when element.complex_type?
17
+ value = build(element.children)
18
+
19
+ unless element.attributes.empty?
20
+ value.merge! collect_attributes(element)
21
+ end
22
+
23
+ value = [value] unless element.singular?
24
+ memo[name] = value
25
+
26
+ end
27
+ end
28
+
29
+ memo
30
+ end
31
+
32
+ private
33
+
34
+ def self.collect_attributes(element)
35
+ element.attributes.each_with_object({}) { |attribute, memo|
36
+ memo["_#{attribute.name}".to_sym] = attribute.base_type
37
+ }
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,35 @@
1
+ require 'httpclient'
2
+
3
+ class Sekken
4
+ class HTTPClient
5
+
6
+ def initialize
7
+ @client = ::HTTPClient.new
8
+ end
9
+
10
+ # Public: Returns the HTTPClient instance to configure.
11
+ attr_reader :client
12
+
13
+ # Public: Executes an HTTP GET request to a given url.
14
+ #
15
+ # Returns the raw HTTP response body as a String.
16
+ def get(url)
17
+ request(:get, url, {}, nil)
18
+ end
19
+
20
+ # Public: Executes an HTTP POST request to a given url with headers and body.
21
+ #
22
+ # Returns the raw HTTP response body as a String.
23
+ def post(url, headers, body)
24
+ request(:post, url, headers, body)
25
+ end
26
+
27
+ private
28
+
29
+ def request(method, url, headers, body)
30
+ response = @client.request(method, url, nil, body, headers)
31
+ response.content
32
+ end
33
+
34
+ end
35
+ end