forked from rubiii/sekken
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e331c49
Showing
174 changed files
with
123,558 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.rvmrc | ||
.DS_Store | ||
doc | ||
coverage | ||
graph | ||
pkg | ||
*~ | ||
*.rbc | ||
*.gem | ||
.rspec | ||
.bundle | ||
Gemfile.lock | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options | ||
language: "ruby" | ||
script: "bundle exec rake --trace" | ||
rvm: | ||
- 1.9.2 | ||
- 1.9.3 | ||
- 2.0 | ||
- jruby-19mode | ||
- rbx | ||
notifications: | ||
irc: "irc.freenode.org#savon" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--markup markdown | ||
--markup-provider redcarpet | ||
- | ||
CHANGELOG.md | ||
LICENSE | ||
lib/**/*.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Contribution Guide | ||
|
||
This page describes how to contribute changes to Sekken. | ||
|
||
Please do not create a pull request without reading this guide first. | ||
Make sure to read the documentation for your version at [savonrb.com](http://savonrb.com/) | ||
and post questions to the [mailing list](https://groups.google.com/forum/#!forum/savonrb). | ||
|
||
**Bug fixes** | ||
|
||
If you really think you found a bug, please make sure to add as many information as possible | ||
to the ticket. You're a developer, we are developers and you know we need tests to reproduce | ||
problems and make sure they don't come back. | ||
|
||
So if you can reproduce your problem in a spec, that would be awesome! If you can't, please | ||
let us know how we could make this easier for you. Also, provide code and the WSDL of the | ||
service your working with so others can try to come up with a spec for your problem. | ||
|
||
After we have a failing spec, it obviously needs to be fixed. Make sure your new spec is the | ||
only failing one under the `spec` directory. Travis only runs the "unit tests" at `spec/sekken`, | ||
but Sekken actually has with some additional "integration/example specs" at `spec/integration`, | ||
which you need to run locally to make sure the integration with real world services still works. | ||
|
||
Notice that these specs are not run by Travis, because the service's are not guaranteed to work | ||
all the time and the specs will timeout after a few seconds when the service is currently down. | ||
|
||
Please follow this basic workflow for pull requests: | ||
|
||
* [Fork the project](https://help.github.com/articles/fork-a-repo) | ||
* Create a feature branch and make your bug fix | ||
* Add tests for it! | ||
* Update the [Changelog](https://github.com/savonrb/sekken/blob/master/CHANGELOG.md) | ||
* [Send a pull request](https://help.github.com/articles/using-pull-requests) | ||
* [Check that your pull request passes the build](https://travis-ci.org/savonrb/sekken/pull_requests) | ||
|
||
|
||
**Improvements and feature requests** | ||
|
||
If you have an idea for an improvement or a new feature, please feel free to | ||
[create a new issue](https://github.com/savonrb/sekken/issues/new) and describe your idea | ||
so that other people can give their insights and opinions. This is also important to avoid | ||
duplicate work. | ||
|
||
Pull requests and issues on GitHub are meant to be used to discuss problems and ideas, | ||
so please make sure to participate and follow up on questions. In case noone comments | ||
on your ticket, please keep updating the ticket with additional information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
source 'https://rubygems.org' | ||
gemspec | ||
|
||
# profiling | ||
#gem 'method_profiler', require: false | ||
#gem 'ruby-prof', require: false # does not work on jruby! | ||
|
||
# coverage | ||
gem 'simplecov', require: false | ||
gem 'coveralls', require: false | ||
|
||
# dependencies | ||
#gem 'rubydeps', require: false # uses c extensions | ||
|
||
# debugging | ||
#gem 'debugger', require: false # don't install on travis! | ||
|
||
platform :rbx do | ||
gem 'json' | ||
gem 'racc' | ||
gem 'rubysl' | ||
gem 'rubinius-coverage' | ||
end | ||
|
||
group :development do | ||
gem 'fuubar' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2011 Daniel Harrington | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Sekken | ||
|
||
Heavy metal SOAP client | ||
|
||
[Documentation](http://savonrb.com) | [RDoc](http://rubydoc.info/gems/savon) | | ||
[Mailing list](https://groups.google.com/forum/#!forum/savonrb) | [Twitter](http://twitter.com/savonrb) | ||
|
||
[](http://travis-ci.org/savonrb/sekken) | ||
[](http://badge.fury.io/rb/sekken) | ||
[](https://codeclimate.com/github/savonrb/sekken) | ||
[](https://coveralls.io/r/savonrb/sekken) | ||
|
||
|
||
## Version 3 | ||
|
||
**Status: Unstable.** Sekken is currently under development and available for testing on GitHub. | ||
Use this version if you can handle changes and want to provide feedback. | ||
|
||
Sekken is still in a very early stage, but [there is some documentation!](http://savonrb.com/version3/) | ||
|
||
## Give back | ||
|
||
If you're using Sekken and you or your company is making money from it, then please consider | ||
donating via [Gittip](https://www.gittip.com/rubiii/) so that I can continue to improve it. | ||
|
||
[](https://www.gittip.com/rubiii/) | ||
|
||
Donate icon from the [Noun Project](http://thenounproject.com/noun/donate/#icon-No285). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new | ||
|
||
desc 'Generate a dependency graph' | ||
task :graph do | ||
system <<-BASH | ||
rm -rf graph | ||
mkdir graph | ||
GRAPH=true rspec | ||
mv rubydeps.dump graph | ||
cd graph | ||
rubydeps --path_filter='lib/sekken' | ||
dot -Tsvg rubydeps.dot > rubydeps.svg | ||
open -a 'Google Chrome' rubydeps.svg | ||
BASH | ||
end | ||
|
||
task default: :spec | ||
task test: :spec |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- coding: utf-8 -*- | ||
require 'logging' | ||
|
||
require 'sekken/version' | ||
require 'sekken/errors' | ||
require 'sekken/wsdl' | ||
require 'sekken/operation' | ||
require 'sekken/httpclient' | ||
|
||
class Sekken | ||
|
||
NS_XSD = 'http://www.w3.org/2001/XMLSchema' | ||
NS_WSDL = 'http://schemas.xmlsoap.org/wsdl/' | ||
|
||
NS_SOAP_1_1 = 'http://schemas.xmlsoap.org/wsdl/soap/' | ||
NS_SOAP_1_2 = 'http://schemas.xmlsoap.org/wsdl/soap12/' | ||
|
||
# Public: Returns the HTTP adapter to use. | ||
def self.http_adapter | ||
@http_adapter ||= HTTPClient | ||
end | ||
|
||
# Public: Sets the HTTP adapter to use. | ||
def self.http_adapter=(adapter) | ||
@http_adapter = adapter | ||
end | ||
|
||
def initialize(wsdl, http = nil) | ||
@http = http || new_http_client | ||
@wsdl = WSDL.new(wsdl, @http) | ||
end | ||
|
||
# Public: Returns the Wasabi instance. | ||
attr_reader :wsdl | ||
|
||
# Public: Returns the HTTP adapter‘s client instance. | ||
def http | ||
@http.client | ||
end | ||
|
||
# Public: Returns the services and ports defined by the WSDL. | ||
def services | ||
@wsdl.services | ||
end | ||
|
||
# Public: Returns an Array of operations for a service and port. | ||
def operations(service_name, port_name) | ||
@wsdl.operations(service_name.to_s, port_name.to_s) | ||
end | ||
|
||
# Public: Returns an Operation by service, port and operation name. | ||
def operation(service_name, port_name, operation_name) | ||
operation = @wsdl.operation(service_name.to_s, port_name.to_s, operation_name.to_s) | ||
verify_operation_style! operation | ||
|
||
Operation.new(operation, @wsdl, @http) | ||
end | ||
|
||
private | ||
|
||
# Private: Returns a new instance of the HTTP adapter to use. | ||
def new_http_client | ||
self.class.http_adapter.new | ||
end | ||
|
||
# Private: Raises if the operation style is not supported. | ||
def verify_operation_style!(operation) | ||
if operation.input_style == 'rpc/encoded' | ||
raise UnsupportedStyleError, | ||
"#{operation.name.inspect} is an #{operation.input_style.inspect} style operation.\n" \ | ||
"Currently this style is not supported." | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
require 'builder' | ||
require 'sekken/message' | ||
|
||
class Sekken | ||
class Envelope | ||
|
||
NSID = 'lol' | ||
|
||
def initialize(operation, header, body) | ||
@logger = Logging.logger[self] | ||
|
||
@operation = operation | ||
@header = header || {} | ||
@body = body || {} | ||
|
||
@nsid_counter = -1 | ||
@namespaces = {} | ||
end | ||
|
||
def register_namespace(namespace) | ||
@namespaces[namespace] ||= create_nsid | ||
end | ||
|
||
def to_s | ||
build_envelope(build_header, build_body) | ||
end | ||
|
||
private | ||
|
||
def create_nsid | ||
@nsid_counter += 1 | ||
"#{NSID}#{@nsid_counter}" | ||
end | ||
|
||
def build_header | ||
return "" if @header.empty? | ||
Message.new(self, @operation.input.header_parts).build(@header) | ||
end | ||
|
||
def build_body | ||
return "" if @body.empty? | ||
body = Message.new(self, @operation.input.body_parts).build(@body) | ||
|
||
if rpc_call? | ||
build_rpc_wrapper(body) | ||
else | ||
body | ||
end | ||
end | ||
|
||
def build_envelope(header, body) | ||
builder = Builder::XmlMarkup.new(indent: 2) | ||
|
||
builder.tag! :env, :Envelope, collect_namespaces do |xml| | ||
xml.tag!(:env, :Header) { |xml| xml << header } | ||
xml.tag!(:env, :Body) { |xml| xml << body } | ||
end | ||
|
||
builder.target! | ||
end | ||
|
||
def build_rpc_wrapper(body) | ||
name = @operation.name | ||
namespace = @operation.binding_operation.input_body[:namespace] | ||
nsid = register_namespace(namespace) if namespace | ||
|
||
tag = [nsid, name].compact.join(':') | ||
|
||
'<%{tag}>%{body}</%{tag}>' % { tag: tag, body: body } | ||
end | ||
|
||
def rpc_call? | ||
@operation.binding_operation.style == 'rpc' | ||
end | ||
|
||
def collect_namespaces | ||
# registered namespaces | ||
namespaces = @namespaces.each_with_object({}) { |(namespace, nsid), memo| | ||
memo["xmlns:#{nsid}"] = namespace | ||
} | ||
|
||
# envelope namespace | ||
namespaces['xmlns:env'] = case @operation.soap_version | ||
when '1.1' then 'http://schemas.xmlsoap.org/soap/envelope/' | ||
when '1.2' then 'http://www.w3.org/2003/05/soap-envelope' | ||
end | ||
|
||
namespaces | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Sekken | ||
|
||
# Public: Base error class. | ||
Error = Class.new(RuntimeError) | ||
|
||
# Public: Raised if the style of an operation is not supported. | ||
UnsupportedStyleError = Class.new(Error) | ||
|
||
end |
Oops, something went wrong.