[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Problem with open-uri

David Sulc

1/12/2007 7:17:00 PM

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....))

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 ?

5 Answers

Chris Hulan

1/12/2007 7:44:00 PM

0


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....))
>
> 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/...
xmlns:tns='uri://www.myoms.net/'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/enco...
xmlns:s0='uri://www.myoms.net/types/'
xmlns:s='http://www.w3.org/2001/XMLS...
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

Gregory Brown

1/12/2007 8:56:00 PM

0

On 1/12/07, David Sulc <davidsulc@gmail.com> 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....))
>
> 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...).read

Daniel Finnie

1/12/2007 9:07:00 PM

0

xml = REXML::Document.new(open("http://myoms.net/soap/oms2....)*.read*)

Try that.

Dan

Gregory Brown wrote:
> On 1/12/07, David Sulc <davidsulc@gmail.com> 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....))
>>
>> 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...).read
>
>

David Sulc

1/12/2007 9:59:00 PM

0

Daniel Finnie wrote:
> xml = REXML::Document.new(open("http://myoms.net/soap/oms2....)*.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 !

Carolina Reb

10/29/2012 6:36:00 AM

0



"NoSpamAtAll" wrote in message news:k6l6k8$up$1@pcls6.std.com...


>BORING

....then get the fuck off this newsgroup, Yid douchebag.