Skip to content

Add some features - #10

Open
Paxa wants to merge 12 commits into
IvanShamatov:masterfrom
Paxa:master
Open

Add some features#10
Paxa wants to merge 12 commits into
IvanShamatov:masterfrom
Paxa:master

Conversation

@Paxa

@Paxa Paxa commented May 2, 2017

Copy link
Copy Markdown

Added:

  • reply_name: param. e.g. soap :action, reply_name: 'ActionReply' do ... end
  • add optional soap:Header
  • add access to response object:
soap :action do
  response.headers = { foo: "bar" }
  response.params = { status: "success" }
  # or
  [{ foo: "bar" }, { status: "success" }]
end
  • attribute keys:
soap :action do
  {
    result: {
      "@status": "success",
      foo: {
        "@active": true,
        "@@content": "bar"
      }
    }
  }
end
# output:
<result status="success">
  <foo active="true">bar</foo>
</result>

If you find this useful, I will add more tests and documentation

@IvanShamatov IvanShamatov left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @Paxa. Thank you for finding that project interesting. As you can see I'm not maintaining it at this moment. Actually that was my first gem ever, so you can find some strange decisions I made back there 4 years ago. If you find it usable in your project, just use fork. But for now I can't merge your PR due to some comments down there. If you would like to talk and even finish it to be production ready I'm open for discussion.
Thanks again,
Ivan

Comment thread Gemfile
# Specify your gem's dependencies in sinatra-soap.gemspec
gemspec

gem 'sinatra', '2.0.0.rc2'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be moved into gemspec (well it's there).

Comment thread .travis.yml Outdated
rvm:
- 1.9.3
- 2.0.0
- 2.4.0

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you like to drop supporting for 1.9 branch without major release? Only major release should make breaking API changes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably updating major version will be right. 1.9 support ended 2 years ago, do you know if anyone still using it? I haven't seen it for years

https://www.ruby-lang.org/en/news/2014/01/10/ruby-1-9-3-will-end-on-2015/

File.join(File.dirname(__FILE__), "..", "views")
end

def hash_to_xml(xml, hash)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be rewritten. Too long method with huge complexity.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. But what you think about this idea in general? (@.. for xml attributes, @@content to create tag with attributes and simple content, converting array list of singularized tags)


def call_action_block
request = Soap::Request.new(env, request, params)
if defined?(logger) && logger

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Soap::Request should know about logging and log request while/before/after execution.

Comment thread lib/sinatra/soap/helper_methods.rb Outdated
rescue Soap::Error => e
builder :error, locals: {e: e}, :views => self.soap_views
if defined?(logger) && logger
logger.info "SOAP Request: #{env['HTTP_SOAPACTION']} - Undefined Soap Action"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not correct. If we catch error that does not mean we catch Undefined Soap Action.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, thanks for point it

Comment thread lib/sinatra/soap/helper_methods.rb Outdated

def get_wsdl
if defined?(logger) && logger
logger.info "SOAP: wsdl request"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats it? seriously? Just log that wsdl request?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was useful in my case to verify if client working correctly or not. Probably just standard sinatra's logging will be enough

def header
return orig_params[:soap_header] unless orig_params[:soap_header].nil?
rack_input = env["rack.input"].read
env["rack.input"].rewind

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single quotes (rubocop)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never understood the point of this rule, afaik now days compiler is smart enough to determine if have interpolations or not...
Will update it when code is production ready

Comment thread sinatra-soap.gemspec
spec.add_development_dependency "rake"
spec.add_development_dependency "rack-test"
spec.add_development_dependency "debugger"
#spec.add_development_dependency "debugger"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you remove debugger out of development dependencies?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only for ruby 1.9.*, I think there was some installation issues with ruby 2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants