From: David Sulc Date: 2007-01-13T05:14:40+09:00 Subject: Re: Problem with open-uri --------------000200000901030500090704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit ChrisH wrote: > David Sulc wrote: > >> 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: > > 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/'> > > attributeFormDefault='qualified' > targetNamespace='uri://www.myoms.net/types/'> > > > 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 ? --------------000200000901030500090704--