Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URI::InvalidURIError #488

Closed
koko37 opened this issue Aug 13, 2013 · 22 comments
Closed

URI::InvalidURIError #488

koko37 opened this issue Aug 13, 2013 · 22 comments

Comments

@koko37
Copy link

koko37 commented Aug 13, 2013

Hello Everybody!

I am trying to build SOAP client, and installed Savon 2.3.0 in gemfile.
And wrote test code, like below.
But while in running, there is an error "URI::InvalidURIError".

Please help me if possible.
Thanks.

def test
    client = Savon.client do
      wsdl "https://api.propertyware.com/pw/services/PWServices?wsdl"
      endpoint "https://api.propertyware.com/pw/services/PWServices"
      namespace "https://api.propertyware.com/pw/services/PWServices"
    end

    response = client.call(:get_contacts_by_name, message: {first_name: "foo" ,last_name: "foo"})
  end
@rubiii
Copy link
Contributor

rubiii commented Aug 26, 2013

tried your code without modifications usng savon 2.3.0 and it's working fine.
are you running this in a test environment? can you try running it "standalone"?

@koko37
Copy link
Author

koko37 commented Aug 28, 2013

I resolved this issue by installing gem 'httpclient'.
thanks.

@koko37 koko37 closed this as completed Aug 28, 2013
@codebender
Copy link

what's the cause of this error? I got it as well after upgrading to 2.3 version of the savon gem. installing gem 'httpclient' also fixed the error...

@bradly-swart
Copy link

Thanks, this helped fix my error too.

I changed to another version of ruby using rbenv, re-installed the savon gem, ran 'rbenv rehash'.
After install the 'httpclient' gem things started working again...well mostly except for the 302 HTTPError I'm getting now.

@johnagan
Copy link

That was an hour of my life I'll never get back :)

Worked for me too! thx

@elsurudo
Copy link

elsurudo commented Oct 3, 2013

Had the same issue. This should probably be documented somewhere. Thanks!

@codebender
Copy link

pretty please, document this.

@tjarratt
Copy link
Contributor

@MisterBender did you ever discover the root cause of this error? I'll gladly document it, but it would be nice to know what is causing this error in the first place.

@marekstachura
Copy link

Hi,

same here, I'm using latest version 2 (v 2.3.3) of the gem and latest Ruby 1.9.3 (1.9.3-p484).
When I call:

client = Savon.client(wsdl: 'https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl')

I'm getting following exception:

/Users/marek/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/uri/common.rb:176:in `split': bad URI(is not URI?): {:host=>"ec.europa.eu", :path=>"/taxation_customs/vies/checkVatService.wsdl", :port=>"80", :query=>nil, :scheme=>"http", :headers=>{}, :body=>nil, :ssl_verify_peer=>true} (URI::InvalidURIError)
from /Users/marek/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/uri/common.rb:211:in `parse'
from /Users/marek/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/uri/common.rb:747:in `parse'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/excon-0.9.6/lib/excon/connection.rb:20:in `initialize'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/httpi-2.1.0/lib/httpi/adapter/excon.rb:17:in `new'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/httpi-2.1.0/lib/httpi/adapter/excon.rb:17:in `initialize'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/httpi-2.1.0/lib/httpi.rb:192:in `new'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/httpi-2.1.0/lib/httpi.rb:192:in `load_adapter'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/httpi-2.1.0/lib/httpi.rb:135:in `request'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/httpi-2.1.0/lib/httpi.rb:106:in `get'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/wasabi-3.2.3/lib/wasabi/resolver.rb:42:in `load_from_remote'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/wasabi-3.2.3/lib/wasabi/resolver.rb:32:in `resolve'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/wasabi-3.2.3/lib/wasabi/document.rb:141:in `xml'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/wasabi-3.2.3/lib/wasabi/document.rb:159:in `parse'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/wasabi-3.2.3/lib/wasabi/document.rb:146:in `parser'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/wasabi-3.2.3/lib/wasabi/document.rb:63:in `soap_actions'
from /Users/marek/.rvm/gems/ruby-1.9.3-p484/gems/savon-2.3.3/lib/savon/client.rb:28:in `operations'
from vies.rb:4:in `<main>'

After installing the gem httpclient it works again.
Thanks.

@catskull
Copy link

catskull commented May 8, 2014

Bump for this.

That was an hour of my life I'll never get back

@tjarratt
Copy link
Contributor

tjarratt commented May 9, 2014

I feel like I'm kind of letting everyone down, because it's pretty clear this is a real issue that has affected a lot of people now, but I still haven't been able to reproduce this.

Gemfile

source :rubygems
gem "savon", "~> 2.3.3"
rvm use ruby-1.9.3@savon-test --create
bundle
bundle exec rib
irb(main):001:0> RUBY_VERSION
=> "1.9.3"
irb(main):002:0> require 'savon'; Savon::VERSION
=> "2.3.3"
irb(main):003:0> Savon.client(wsdl: 'https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl').operations

No exceptions. The backtrace that @marekstachura posted mentioned Excon as the adapter, so it makes some sense that adding HTTPClient might fix this, because it changes the http adapter Savon uses, and the URI generated goes through a separate path.

However, the version of Excon in the trace is 0.9.6 which was released on 02/22/12, so... it would be somewhat surprising if that worked without any bugs.

@catskull -- since you were the last person to encounter this, could you tell me which http adapter you're using, and which version if it is in your Gemfile.lock ?

@jonathan-mui
Copy link

I experienced this issue with an existing app today. After adding gem 'httpclient' I no longer saw the issue. Removing the gem after brought the issue back, so for my app it was definitely the culprit. However, I tried to create a minimalist case with a new rails app and same ruby and gem versions, but could not reproduce the issue. My stack trace is similar. How do I find out which http adapter I'm using?

URI::InvalidURIError: bad URI(is not URI?): {:host=>"secure.echosign.com", :path=>"/services/EchoSignDocumentService18", :port=>"443", :query=>"wsdl", :scheme=>"https", :headers=>{}, :body=>nil, :ssl_verify_peer=>true}
    from /Users/<user>/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/common.rb:176:in `split'
    from /Users/<user>/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/common.rb:211:in `parse'
    from /Users/<user>/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/common.rb:747:in `parse'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/excon-0.16.10/lib/excon/connection.rb:20:in `initialize'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/httpi-2.1.0/lib/httpi/adapter/excon.rb:17:in `new'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/httpi-2.1.0/lib/httpi/adapter/excon.rb:17:in `initialize'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/httpi-2.1.0/lib/httpi.rb:192:in `new'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/httpi-2.1.0/lib/httpi.rb:192:in `load_adapter'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/httpi-2.1.0/lib/httpi.rb:135:in `request'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/httpi-2.1.0/lib/httpi.rb:106:in `get'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/wasabi-3.2.3/lib/wasabi/resolver.rb:42:in `load_from_remote'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/wasabi-3.2.3/lib/wasabi/resolver.rb:32:in `resolve'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/wasabi-3.2.3/lib/wasabi/document.rb:141:in `xml'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/wasabi-3.2.3/lib/wasabi/document.rb:159:in `parse'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/wasabi-3.2.3/lib/wasabi/document.rb:146:in `parser'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/wasabi-3.2.3/lib/wasabi/document.rb:63:in `soap_actions'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/savon-2.3.3/lib/savon/client.rb:28:in `operations'
    from (irb):5
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/railties-3.2.18/lib/rails/commands/console.rb:47:in `start'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/railties-3.2.18/lib/rails/commands/console.rb:8:in `start'
    from /Users/<user>/.rvm/gems/ruby-2.1.1@<gemset>/gems/railties-3.2.18/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

@tjarratt
Copy link
Contributor

@jonathan-mui the current adapter can be found on the HTTPI namespace.

HTTPI::Adapter.use # :httpclient by default

There's an order that HTTPI attempts to load them in...

    LOAD_ORDER = [:httpclient, :curb, :em_http, :excon, :net_http, :net_http_persistent]

@jonathan-mui
Copy link

Without the httpclient gem, the adapter used is :excon

@catskull
Copy link

@tjarratt I installed httpclient, which installed httpclient (2.3.4.1). Also noted that I'm using Rails 3.2.11. Not sure which version of rails you're using for testing, but that could be something to start with.

I also blogged about it here.

Not trying to nerd rage too hard, your gem has been super helpful. Just a heads up in the readme or something would be nice.

@tjarratt
Copy link
Contributor

Might be a good idea to link to this issue from your blog post @catskull. I really thought that the "will not do anything" part was going to link here :)

Writing a good README is tough. I think there's a pretty good argument to be made for a FAQ, or maybe a wiki to document some of these challenges people have with Savon. Thoughts?

Honestly, when I have problems like this (which is basically every single day of my life 💣) I end up spending a lot of time searching for very specific error messages on google, which almost always links me to a Stack Overflow or Github page with some pretty helpful discussion that helps direct me to what I need to change.

@tjarratt
Copy link
Contributor

Maybe I'm coming at this from the wrong direction. What if we put a hard dependency on httpclient in Savon, to help minimize these problems? It seems like that works 99% of the time for everyone...

@catskull
Copy link

Good point, I will update my blog to point here.

I really think that all you'd need to do is update the README to read something like:

Savon version 2 is available through Rubygems and can be installed via:
$ gem install savon
or add it to your Gemfile like this:
gem 'savon', '~> 2.3.0'

Some users have reported an error reading URI::InvalidURIError. If you see this as well, a solution is installing httpclient:
$ gem install httpclient
or add it to your Gemfile:
gem 'httpclient'

Otherwise, a hard dependency may make sense, but I squirm thinking that there may be that one person out there that doesn't need it. I guess at the end of the day, it's not really a big deal to have a dependency.

As for your problem solving (:bomb:) skills, that's essentially what I did, which led me here. And that's kind of what I mean when I quoted

That was an hour of my life I'll never get back

because it seemed like such a small issue with a really easy fix. We should all spend that time researching things that don't have straightforward/easy solutions! 😄

@tjarratt
Copy link
Contributor

tjarratt commented Jul 1, 2014

Cool, updating the README to include a small FAQ. Will try adding to that as I see more patterns in community issues evolve.

tjarratt added a commit that referenced this issue Jul 1, 2014
@codebender
Copy link

👍

@Bodata
Copy link

Bodata commented May 11, 2017

Hi,
installed savon-2.11.1 on an older linux system, ruby 1.9x
I had the same error, after a gem install httpclient the problem was solved.

@tjarratt
Copy link
Contributor

tjarratt commented May 11, 2017 via email

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

No branches or pull requests