Running with Ruby

Tag: HTTP (page 2 of 4)

Using Savon Rb to communicate with SOAP client (http basic authentication and no WSDL file)

Most of the time, when we connect to webservices via SOAP (via SOAP! via SOAP! ;)), we have a WSDL file either local or downloaded from a server. But sometimes we need to connect to SOAP server which does not have this file and it is secured with http basic authentication.

To communicate with SOAP I use Savon Rb. It is easy and relatively fast. However in documentation there is nothing about communication with http basic authentication protected resources.

Although setting things up is really easy. First authentication:

@soap_client = Savon::Client.new do
  # Set basic authorization
  http.auth.basic "user_name", "password"
end

and non-wsdl connection:

@soap_client = Savon::Client.new do
  wsdl.endpoint = "http://service.example.com"
  wsdl.namespace = "http://v1.example.com"
end

and that’s all. Now we can execute remote method like this:

@soap_client.request :get_items

or with params:

@last_response = @soap_client.request :get_items do
  soap.body = {
    :param_1 => "value_1",
    :param_2 => "value_2",
  }
end

Padrino + Thin Web Server – uninitialized constant Thin::HttpParser (NameError)

New server, new thin, new error while executing:

Padrino/0.9.19 has taken the stage production on 3001
Thin web server (v1.2.8 codename Black Keys)
Maximum connections set to 1024
Listening on localhost:3001, CTRL+C to stop
`initialize': uninitialized constant Thin::HttpParser (NameError)
/thin-1.2.8/lib/thin/connection.rb:35:in `new'
/thin-1.2.8/lib/thin/connection.rb:35:in `post_init'
/eventmachine-0.12.10/lib/em/connection.rb:45:in `new'
/eventmachine-0.12.10/lib/em/connection.rb:36:in `instance_eval'
/eventmachine-0.12.10/lib/em/connection.rb:36:in `new'
/eventmachine-0.12.10/lib/eventmachine.rb:1430:in `event_callback'

Error occurred because there were some old (incompatible) native C extensions after OS upgrade. To fix this just reinstall Thin:

gem uninstall thin
gem install thin

If Thin version changed, you’ll also need to run:

bundle install
Olderposts Newerposts

Copyright © 2017 Running with Ruby

Theme by Anders NorenUp ↑