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):
<?xml version="1.0" encoding="UTF-8"?>
<ping>
<CommandStatus>
<code>OK</code>
<transit>0.089925</transit>
</CommandStatus>
<command>
<name>ping</name>
</command>
<server_response>
...just a few strings in here
</server_response>
</ping>
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: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
(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.
If the problem is easily solvable on my end, that would be awesome. But
if it is something wrong on their end then I can probably get that
fixed, I guess I just need to know exactly what is wrong.
Any help would be greatly appreciated.
Thanks,
Michael
···
--
Posted via http://www.ruby-forum.com/.