Skip to content

Commit

Permalink
Merge remote-tracking branch 'savon/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	lib/savon/options.rb
  • Loading branch information
ekzobrain committed Jul 6, 2023
2 parents 7ca8292 + e862e70 commit 11f70a8
Show file tree
Hide file tree
Showing 51 changed files with 291 additions and 451 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
{
"name": "Ruby",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/ruby:0-3-bullseye"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "ruby --version",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Ruby

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [2.7, 3.0, 3.1, 3.2, head, truffleruby-head]
env:
RAILS_ENV: test
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # bundle installs and caches dependencies
- name: Run tests
run: bundle exec rake --trace
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.rvmrc
.byebug_history
.DS_Store
.yardoc
.ruby-version
Expand All @@ -13,3 +14,4 @@ tmp
.rspec
Gemfile.lock
bin/
.rspec_status
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
# Savon changelog

## Unreleased
* Add your PR changelog line here

## 2.14.0 (2022-12-16)

* BC BREAKING Fix: [#985](https://github.com/savonrb/savon/pull/985) Renamed `Savon::Response#hash` to `Savon::Response#full_hash`
* BC BREAKING Fix: [#988](https://github.com/savonrb/savon/pull/988) Savon no longer monkeypatches `String#snakecase`
* Fix: [#989](https://github.com/savonrb/savon/pull/989) Do not include xmlns from WSDL, which breaks some servers

## 2.13.1 (2022-09-04)

* Fix: [#977](https://github.com/savonrb/savon/pull/977) Prevent "xmlns:xmlns" namespace but allow "xmlns" namespace.

## 2.13.0 (2022-08-03)

* Drop support for ruby 2.6 and below. Added Ruby 3.0 and 3.1 to test matrix.
* Fix: [#868](https://github.com/savonrb/savon/pull/868) Remove `xmlns:wsa`'s already added elsewhere; select Content-Type HTTP header based on SOAP version.
* Fix: [#943](https://github.com/savonrb/savon/pull/943) Read all namespaces from wsdl definition if document exists
* Feature: [#920](https://github.com/savonrb/savon/pull/920) Add a `write_timeout` setter for HTTP requests
* Feature: [#930](https://github.com/savonrb/savon/pull/930) Add options for SSL min_version/max_version support
* Add your PR changelog line here
* Feature: [#931](https://github.com/savonrb/savon/pull/931) Add `log_headers` option

## 2.12.1 (2020-07-05)

Expand Down
21 changes: 10 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,30 @@ 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 can make this easier for you. Also, provide code and the WSDL of the
service you're working with so others can try to come up with a spec for your problem.
service you're 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/savon`,
After we have a failing spec, it needs to be fixed. Make sure your new spec is the
only failing one under the `spec` directory. CI only runs the "unit tests" at `spec/savon`,
but Savon actually has some additional specs at `spec/integration`, which you need to run locally
to make sure the integration with real world services still works.
to make sure the integration with real-world services still works.

These specs are not run by Travis, because the services are not guaranteed to work all the time.
These specs are not run by CI, because the services are not guaranteed to work all the time.

Please follow this basic workflow for pull requests:
Please follow this 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!
* [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/savon/pull_requests)

* [Send a Pull Request](https://help.github.com/articles/using-pull-requests)
* [Check that your Pull Request passes the build](https://github.com/savonrb/savon/actions?query=workflow%3ARuby)

**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/savon/issues/new/choose) and describe your idea
[create a new Issue](https://github.com/savonrb/savon/issues/new/choose) 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,
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 no one comments
on your ticket, please keep updating the ticket with additional information.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
source 'https://rubygems.org'

gemspec

gem "httpclient", "~> 2.7.1"

gem "simplecov", :require => false
gem "coveralls", :require => false
gem "net-smtp" if RUBY_VERSION >= "3.1.0"
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

Heavy metal SOAP client

[Documentation](https://www.rubydoc.info/gems/savon/) | [Support](https://stackoverflow.com/questions/tagged/savon) |
[Documentation](https://www.rubydoc.info/gems/savon/) | [Support](https://stackoverflow.com/questions/tagged/savon) |
[Mailing list](https://groups.google.com/forum/#!forum/savonrb) | [Twitter](http://twitter.com/savonrb)

[![Build Status](https://secure.travis-ci.org/savonrb/savon.svg?branch=master)](http://travis-ci.org/savonrb/savon)
[![Ruby](https://github.com/savonrb/savon/actions/workflows/ci.yml/badge.svg)](https://github.com/savonrb/savon/actions/workflows/ci.yml)
[![Gem Version](https://badge.fury.io/rb/savon.svg)](http://badge.fury.io/rb/savon)
[![Code Climate](https://codeclimate.com/github/savonrb/savon.svg)](https://codeclimate.com/github/savonrb/savon)
[![Coverage Status](https://coveralls.io/repos/savonrb/savon/badge.svg)](https://coveralls.io/r/savonrb/savon)
Expand All @@ -22,7 +22,7 @@ $ gem install savon
or add it to your Gemfile like this:

```
gem 'savon', '~> 2.12.0'
gem 'savon', '~> 2.13.0'
```

## Usage example
Expand All @@ -33,6 +33,12 @@ require 'savon'
# create a client for the service
client = Savon.client(wsdl: 'http://service.example.com?wsdl')

# or: create a client with a wsdl provided as a string
client = Savon.client do |config|
wsdl_content = File.read("/path/to/wsdl")
config.wsdl wsdl_content
end

client.operations
# => [:find_user, :list_users]

Expand All @@ -48,7 +54,7 @@ For more examples, you should check out the

## Ruby version support

* `master` - MRI 2.5, 2.6, 2.7 (same support as Ruby)
* `master` - MRI 2.7, 3.0, 3.1 (same support as Ruby)
* 2.12.x - MRI 2.2, 2.3, 2.4, 2.5
* 2.11.x - MRI 2.0, 2.1, 2.2, and 2.3

Expand All @@ -70,5 +76,3 @@ $ bundle exec rspec
## Documentation

Please be sure to [read the documentation](https://www.rubydoc.info/github/savonrb/savon/).


10 changes: 10 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
_You'll need write access to the repository and the [rubygems](https://rubygems.org/gems/savon) project to create a release._

1. On master, edit [CHANGELOG.md](https://github.com/savonrb/savon/blob/master/CHANGELOG.md) to finalize the new version number and list of all changes.
2. Bump [version.rb](https://github.com/savonrb/savon/blob/master/lib/savon/version.rb) to the version you picked in previous step.
3. **Final check**: make sure all tests are green, and that `gem build savon.gemspec` on master succeeds. If not, merge any fixes back to master and go to step 1.
4. [Draft a new release](https://github.com/savonrb/savon/releases/new) on Github.
- Create a tag matching the version in previous step - e.g. `v2.12.1` - prepend the version number with a "v".
- Use `v[version]` for the release title, and copy the changelog into the release notes.
- Click "Publish release" to commit the tag on Github.
5. `git checkout` the newly commited tag, then `gem build savon.gemspec` to build the gem package locally. Use `gem push savon-[version].gem` to publish to rubygems.
Binary file removed donate.png
Binary file not shown.
1 change: 1 addition & 0 deletions lib/savon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ def self.notify_observers(operation_name, builder, globals, locals)
require "savon/version"
require "savon/client"
require "savon/model"
require "savon/string_utils"
16 changes: 14 additions & 2 deletions lib/savon/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ def namespaces
namespaces["xmlns#{env_namespace && env_namespace != "" ? ":#{env_namespace}" : ''}"] =
SOAP_NAMESPACE[@globals[:soap_version]]

if @wsdl&.document
@wsdl.parser.namespaces.each do |identifier, path|
next if identifier == 'xmlns' # Do not include xmlns namespace as this causes issues for some servers (https://github.com/savonrb/savon/issues/986)

prefixed_identifier = "xmlns:#{identifier}"

next if namespaces.key?(prefixed_identifier)

namespaces[prefixed_identifier] = path
end
end

namespaces
end
end
Expand Down Expand Up @@ -156,9 +168,9 @@ def serialized_messages
message_tag = serialized_message_tag[1]
@wsdl.soap_input(@operation_name.to_sym)[message_tag].each_pair do |message, type|
break if @locals[:message].nil?
message_locals = @locals[:message][message.snakecase.to_sym]
message_locals = @locals[:message][StringUtils.snakecase(message).to_sym]
message_content = Message.new(message_tag, namespace_identifier, @types, @used_namespaces, message_locals, :unqualified, @globals[:convert_request_keys_to], @globals[:unwrap]).to_s
messages << "<#{message} xsi:type=\"#{type.join(':')}\">#{message_content}</#{message}>"
messages += "<#{message} xsi:type=\"#{type.join(':')}\">#{message_content}</#{message}>"
end
messages
end
Expand Down
30 changes: 0 additions & 30 deletions lib/savon/core_ext/string.rb

This file was deleted.

6 changes: 3 additions & 3 deletions lib/savon/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def all_operations
# Defines a class-level SOAP operation.
def define_class_operation(operation)
class_operation_module.module_eval %{
def #{operation.to_s.snakecase}(locals = {})
def #{StringUtils.snakecase(operation.to_s)}(locals = {})
client.call #{operation.inspect}, locals
end
}
Expand All @@ -38,8 +38,8 @@ def #{operation.to_s.snakecase}(locals = {})
# Defines an instance-level SOAP operation.
def define_instance_operation(operation)
instance_operation_module.module_eval %{
def #{operation.to_s.snakecase}(locals = {})
self.class.#{operation.to_s.snakecase} locals
def #{StringUtils.snakecase(operation.to_s)}(locals = {})
self.class.#{StringUtils.snakecase(operation.to_s)} locals
end
}
end
Expand Down
27 changes: 11 additions & 16 deletions lib/savon/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ def initialize(options = {})
:namespaces => {},
:logger => Logger.new($stdout),
:log => false,
:log_headers => true,
:filters => [],
:pretty_print_xml => false,
:raise_errors => true,
:strip_namespaces => true,
:delete_namespace_attributes => false,
:convert_response_tags_to => lambda { |tag| tag.snakecase.to_sym },
:convert_attributes_to => lambda { |k, v| [k, v] },
:convert_response_tags_to => lambda { |tag| StringUtils.snakecase(tag).to_sym},
:convert_attributes_to => lambda { |k,v| [k,v] },
:multipart => false,
:adapter => nil,
:use_wsa_headers => false,
Expand Down Expand Up @@ -197,13 +198,13 @@ def raise_errors(raise_errors)

# Whether or not to log.
def log(log)
HTTPI.log = log
HTTPI.log = log
@options[:log] = log
end

# The logger to use. Defaults to a Savon::Logger instance.
def logger(logger)
HTTPI.logger = logger
HTTPI.logger = logger
@options[:logger] = logger
end

Expand All @@ -219,6 +220,11 @@ def log_level(level)
@options[:logger].level = levels[level]
end

# To log headers or not.
def log_headers(log_headers)
@options[:log_headers] = log_headers
end

# A list of XML tags to filter from logged SOAP messages.
def filters(*filters)
@options[:filters] = filters.flatten
Expand Down Expand Up @@ -383,8 +389,7 @@ def initialize(options = {})
defaults = {
:advanced_typecasting => true,
:response_parser => :nokogiri,
:multipart => false,
:mtom => false
:multipart => false
}

super defaults.merge(options)
Expand Down Expand Up @@ -447,11 +452,6 @@ def attachments(attachments)
@options[:attachments] = attachments
end

# Instruct Savon to send attachments using MTOM https://www.w3.org/TR/soap12-mtom/
def mtom(mtom)
@options[:mtom] = mtom
end

# Value of the SOAPAction HTTP header.
def soap_action(soap_action)
@options[:soap_action] = soap_action
Expand All @@ -477,11 +477,6 @@ def response_parser(parser)
@options[:response_parser] = parser
end

# Pass already configured Nori instance.
def nori(nori)
@options[:nori] = nori
end

# Instruct Savon to create a multipart response if available.
def multipart(multipart)
@options[:multipart] = multipart
Expand Down
4 changes: 2 additions & 2 deletions lib/savon/qualified_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def add_namespaces_to_values(values, path)
Array(values).collect do |value|
translated_value = translate_tag(value)
namespace_path = path + [translated_value]
namespace = @used_namespaces[namespace_path]
namespace.blank? ? value : "#{namespace}:#{translated_value}"
namespace = @used_namespaces[namespace_path] || ''
namespace.empty? ? value : "#{namespace}:#{translated_value}"
end
end
end
Expand Down
Loading

0 comments on commit 11f70a8

Please sign in to comment.