Problem with open-uri

D

David Sulc

Hi !

I'm unable to open certain URIs with open-uri. Here is the code :

require 'rexml/document'
require 'open-uri'
xml = REXML::Document.new(open("http://myoms.net/soap/oms2.wsdl"))

The error I get is :

/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:133:in `stream=': Tempfile
is not a valid input stream. It must be (RuntimeError)
either a String, IO, StringIO or Source.

I have tried to "cast" the parameter to IO with to_io, but it still
doesn't work. Any ideas ?
 
C

ChrisH

David said:
Hi !

I'm unable to open certain URIs with open-uri. Here is the code :

require 'rexml/document'
require 'open-uri'
xml = REXML::Document.new(open("http://myoms.net/soap/oms2.wsdl"))

The error I get is :

/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:133:in `stream=': Tempfile
is not a valid input stream. It must be (RuntimeError)
either a String, IO, StringIO or Source.

ran that above code and it worked:
<?xml version='1.0' encoding='UTF-8'?>
<definitions name='OnlineMessengerService'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='uri://www.myoms.net/'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:s0='uri://www.myoms.net/types/'
xmlns:s='http://www.w3.org/2001/XMLSchema'
targetNamespace='uri://www.myoms.net/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<types>
<s:schema elementFormDefault='qualified'
attributeFormDefault='qualified'
targetNamespace='uri://www.myoms.net/types/'>
<s:complexType name='Time'>
<s:sequence>
<s:element maxOccurs='1' name='year' minOccurs='1'
nillable='false' type='s:long'/>
.....

Maybe provide the actual code you are running, if it is not exaclty the
above.

Cheers
 
G

Gregory Brown

Hi !

I'm unable to open certain URIs with open-uri. Here is the code :

require 'rexml/document'
require 'open-uri'
xml = REXML::Document.new(open("http://myoms.net/soap/oms2.wsdl"))

The error I get is :

/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:133:in `stream=': Tempfile
is not a valid input stream. It must be (RuntimeError)
either a String, IO, StringIO or Source.

I have tried to "cast" the parameter to IO with to_io, but it still
doesn't work. Any ideas ?

if it works on strings just do

open("http://myurl.com").read
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top