Topic: Soap working in irb not in console

Hello,

I am trying to consume some web service based on soap.
I started with some tests with irb (ruby 1.8.7) and they worked perfectly.
When I try the exact same test in the rails console (rails 2.1.2) it is not working and I get the following error

soapi = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
RuntimeError: Cannot connect to https://www.ovh.com/soapi/soapi-re-1.54.wsdl (Not HTTP.)
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/soap/netHttpClient.rb:145:in `create_connection'
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/soap/netHttpClient.rb:113:in `start'
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/soap/netHttpClient.rb:104:in `get_content'
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/wsdl/xmlSchema/importer.rb:64:in `fetch'
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/wsdl/xmlSchema/importer.rb:30:in `import'
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/wsdl/importer.rb:18:in `import'
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/soap/wsdlDriver.rb:124:in `import'
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/soap/wsdlDriver.rb:28:in `initialize'
  from (irb):17:in `new'
  from (irb):17

Any idea why?
Thanks
Nicolas

Re: Soap working in irb not in console

This smacks of an ssl issue (You are using https and it looks like the SOAP::WSDLDriverFactory is complaining that it's not http) but I'm not sure why that may be.
Possibly missing ssl library/gem of some description in your app?

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Soap working in irb not in console

thanks for your answer, I don't see what I am missing and what is strange is that this working with irb but not with rails console

Re: Soap working in irb not in console

To understand the solution first you must narrow down/  eliminate the suspected causes
Try to prove if it's an ssl issue. Use an http address.
If http works then at least you have a starting point.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Soap working in irb not in console

Hello, I had tried also but http is not working either and this script works

require 'soap/wsdlDriver'
  
  wsdl = 'https://www.ovh.com/soapi/soapi-re-1.54.wsdl'
  soapi = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver

  #login
  session = soapi.login(account, psw, 'fr', false)

  #accountSummary
  @result = soapi.telephonySmsCreditLeft(session, user)
  puts @result

  #logout
  soapi.logout(session);
  puts "logout successfull"

but the same code in my rails app controller doesn't

Re: Soap working in irb not in console

I'm sorry, without being able to see the stack traces, error logs etc... I'm at a total loss.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Soap working in irb not in console

Hello James,

In fact you may be right and it could be ssl related. Part of my tests I installed savon which raised a ssl error

I found this monkey patch monkey patch which could be related to my problem.

I'll try to figure out how to use it and come back here for report

Nicolas

Re: Soap working in irb not in console

I digged a little bit more and check the url class provided and in fact irb (ruby) considers it at URI::HTTPS where rails thinks its URI::Generic (a case not tested in soap/netHttpClient.rb)

Any idea why is that?