From: Michael Neumann Date: 2008-07-08T07:40:03+09:00 Subject: Re: XMLRPC Question Michael Taras wrote: > I am working on a little project that requires me to interface with an > XMLRPC server they have to grab some data. To first test it, I just > telneted into the server and ran their test function, which was "ping". > It returned a response like so (the server_response area had some > private data so I left it out): > > > > > OK > 0.089925 > > > ping > > > ...just a few strings in here > > > > > So after that, I set out to see if I could get the same information from > my ruby script, and I wrote the following script: > > require 'xmlrpc/client' > require 'pp' > > server = XMLRPC::Client.new2("server_info_in_here") > result = server.call("ping") > > pp result > > > However, when I run that script it errors out on the line with > server.call in it. The error that it spits out is: > > /usr/local/lib/ruby/1.8/net/http.rb:2019:in `read_status_line': wrong > status line: "" > (Net::HTTPBadResponse) > from /usr/local/lib/ruby/1.8/net/http.rb:2006:in `read_new' > from /usr/local/lib/ruby/1.8/net/http.rb:1047:in `request' > from /usr/local/lib/ruby/1.8/net/http.rb:1034:in `request' > from /usr/local/lib/ruby/1.8/net/http.rb:543:in `start' > from /usr/local/lib/ruby/1.8/net/http.rb:1032:in `request' > from /usr/local/lib/ruby/1.8/net/http.rb:989:in `post2' > from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:535:in `do_rpc' > from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2' > from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:410:in `call' > from test.rb:5 > > Just from my research, it seems that the error is popping up because the > code is trying to match the xml definition line to an HTTP response > code, which of course is not working. My guess is that the server is > not returning any sort of http status, and just the xml, but I'm really > not sure. This is my first time messing with any xmlrpc stuff. I think your analysis is correct. The server is returning the plain XML and not a HTTP request. Btw, what did you enter in telnet? And what did you got as a result from telnet? XML-RPC is usually served via HTTP. IIRC it is even required. If you use XML-RPC not over HTTP, then you need to fetch the response yourself (you can use plain sockets) and then invoke the parser on it yourself. But it's probably easier to take a look at the server, because it's very uncommon to not use HTTP! And btw, are you sure that the XML shown above is valid XML-RPC? AFAIK it's not! Yeah, it's not XML-RPC ;-) Regards, Michael