Problem with open-uri

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 ?

On 1/12/07, David S. [email protected] wrote:

/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

David S. wrote:

/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'?>



<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

xml =
REXML::Document.new(open(“http://myoms.net/soap/oms2.wsdl”).read)

Try that.

Dan

Daniel F. wrote:

xml = REXML::Document.new(open(“http://myoms.net/soap/oms2.wsdl”).read)

Try that.

Dan

That seems to work. I had tried, but apparently with the wrong syntax.

I have a few errors in my script, so I can really test it right now…

Thanks a lot !

ChrisH wrote:

The error I get is :
xmlns:tns=‘uri://www.myoms.net/’
<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.

The code I run is different, however this simple example fails too.

What I really don’t understand is that if I give a different URL (such
as “http://www.webservicex.net/genericbarcode.asmx?wsdl”), it’s OK.

The complete error stack trace 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. from /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:100:in initialize’
from /usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:8:in
initialize' from /usr/lib/ruby/1.8/rexml/document.rb:178:in build’
from /usr/lib/ruby/1.8/rexml/document.rb:45:in `initialize’
from test.rb:3

When I reaserched this, all I was able to discover was that it seems to
be a problem with Ruby’s duck typing
(http://community.livejournal.com/evan_tech/173207.html) and/or REXML.

Any ideas ?