josephholsten / rets4r

Bringing RETS to ruby
MIT License
52 stars 28 forks source link

Unable to parse XML on first try due to 'undefined method `each' for #<String: #25

Closed rachaelroland closed 12 years ago

rachaelroland commented 12 years ago

I removed the gem and added it as a submodule and the problem went away.

josephholsten commented 12 years ago

Neat, you've found a ruby 1.9 comparability bug. String removed the each method in favor of separate each_char, each_byte, each_codepoint, &c.

Sorry about that. I'll patch and get a new release out quick.

On Jan 24, 2012, at 2:38 PM, Eric Rolandreply@reply.github.com wrote:

I am trying to log into RIMLS:

 client = RETS4R::Client.new('http://ris.retsiq.com/rets/login')
 client.logger = @@importer_logger
 client.set_pre_request_block do |rets, http, headers|
   headers["User-Agent"] = "RETS4R/0.8.5"
 end
 client.login('someusername', 'somepassword')

And it is throwing a parsing exception:

RETS4R::Client::ParserException: #RETS4R::Client::ParserException:0x007f92bd9b1bd8 from /Users/Eric/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-0.8.5/lib/rets4r/client/parser/rexml.rb:54:in rescue in parse' from /Users/Eric/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-0.8.5/lib/rets4r/client/parser/rexml.rb:38:inparse' from /Users/Eric/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-0.8.5/lib/rets4r/client/parser/rexml.rb:46:in rescue in parse' from /Users/Eric/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-0.8.5/lib/rets4r/client/parser/rexml.rb:38:inparse' from /Users/Eric/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-0.8.5/lib/rets4r/client.rb:163:in parse' from /Users/Eric/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-0.8.5/lib/rets4r/client.rb:274:inlogin'

Log:

-> "HTTP/1.1 200 OK\r\n"

-> "Set-Cookie: JSESSIONID=0EC465C71AE7A1C5EC089917C8C482CF; Path=/\r\n"

-> "Set-Cookie: JSESSIONID=0EC465C71AE7A1C5EC089917C8C482CF; Path=/\r\n"

-> "MIME-Version: 1.0\r\n"

-> "Cache-Control: private\r\n"

-> "RETS-Version: RETS/1.7\r\n"

-> "X-AspNet-Version: 2.0.50727\r\n"

-> "Date: Tue, 24 Jan 2012 22:30:48 GMT\r\n"

-> "Set-Cookie: ASP.NET_SessionId=ibj2ebzs4gt1qwypfyt5r555; path=/; HttpOnly\r\n"

-> "Set-Cookie: RETS-Session-ID=ibj2ebzs4gt1qwypfyt5r555; path=/\r\n"

-> "RETS-Server: Interealty-RETS/1.5.247.0\r\n"

-> "Server: Microsoft-IIS/6.0\r\n"

-> "Cache-Control: private\r\n"

-> "Cache-Control: private, max-age=0\r\n"

-> "WWW-Authenticate: Digest realm=\"rets@retsiq.com\",qop=\"auth\",nonce=\"8bcfc4871b7be2d7074251b025fde500\", opaque=\"3005cbc41daa2\"\r\n"

-> "Content-Type: text/xml\r\n"

-> "Content-Length: 541\r\n"

-> "\r\n"

reading 541 bytes...

-> "<RETS ReplyCode=\"0\" ReplyText=\"Success. Reference ID: 30f47c5d-e10d-4253-aab7-fbd51a294441\">\r\n\r\nMemberName=Some User\r\nUser=Some Broker\r\nBroker=Some Broker\r\nMetadataVersion=30.15.91715\r\nMetadataTimestamp=Fri, 20 Jan 2012 15:28:35 GMT\r\nMinMetadataTimestamp=Fri, 20 Jan 2012 15:28:35 GMT\r\nTimeoutSeconds=3600\r\nChangePassword=/rets/changepassword\r\nGetMetadata=/rets/getmetadata\r\nGetObject=/rets/getobject\r\nLogin=/rets/login\r\nLogout=/rets/logout\r\nSearch=/rets/search\r\nX-Selector=/rets/selector\r\n\r\n\r\n"

read 541 bytes

Conn keep-alive

Response headers: {"set-cookie"=>["JSESSIONID=0EC465C71AE7A1C5EC089917C8C482CF; Path=/", "JSESSIONID=0EC465C71AE7A1C5EC089917C8C482CF; Path=/", "ASP.NET_SessionId=ibj2ebzs4gt1qwypfyt5r555; path=/; HttpOnly", "RETS-Session-ID=ibj2ebzs4gt1qwypfyt5r555; path=/"], "mime-version"=>["1.0"], "cache-control"=>["private", "private", "private, max-age=0"], "rets-version"=>["RETS/1.7"], "x-aspnet-version"=>["2.0.50727"], "date"=>["Tue, 24 Jan 2012 22:30:48 GMT"], "rets-server"=>["Interealty-RETS/1.5.247.0"], "server"=>["Microsoft-IIS/6.0"], "www-authenticate"=>["Digest realm=\"rets@retsiq.com\",qop=\"auth\",nonce=\"8bcfc4871b7be2d7074251b025fde500\", opaque=\"3005cbc41daa2\""], "content-type"=>["text/xml"], "content-length"=>["541"]} Set header 'Cookie' to 'JSESSIONID=0EC465C71AE7A1C5EC089917C8C482CF; JSESSIONID=0EC465C71AE7A1C5EC089917C8C482CF; ASP.NET_SessionId=ibj2ebzs4gt1qwypfyt5r555; RETS-Session-ID=ibj2ebzs4gt1qwypfyt5r555'

MemberName=Some Body User=Some Info Broker=Some Broker MetadataVersion=30.15.91715 MetadataTimestamp=Fri, 20 Jan 2012 15:28:35 GMT MinMetadataTimestamp=Fri, 20 Jan 2012 15:28:35 GMT TimeoutSeconds=3600 ChangePassword=/rets/changepassword GetMetadata=/rets/getmetadata GetObject=/rets/getobject Login=/rets/login Logout=/rets/logout Search=/rets/search X-Selector=/rets/selector

Unable to parse XML on first try due to 'undefined method `each' for #String:0x007f92bd9b3528'. Now retrying. REXML parser was unable to parse XML: NilClass is not a valid input stream. It must walk like either a String, an IO, or a Source. Unparsable XML was:

Any ideas? Rails 3.0.9 Ruby 1.9.2


Reply to this email directly or view it on GitHub: https://github.com/josephholsten/rets4r/issues/25