开发者

XML-RPC over SSL with Ruby: end of file reached (EOFError)

开发者 https://www.devze.com 2022-12-28 22:24 出处:网络
I have some very simple Ruby code that is attempting to do XML-RPC over SSL: require \'xmlrpc/client\'

I have some very simple Ruby code that is attempting to do XML-RPC over SSL:


require 'xmlrpc/client'
require 'pp'

server = XMLRPC::Client.new2("https://%s:%d/" % [ 'api.ultradns.net', 8755 ])
pp server.call2('UDNS_OpenConne开发者_JS百科ction', 'sponsor', 'username', 'password')

The problem is that it always results in the following EOFError exception:


/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:135:in `sysread': end of file reached (EOFError)

So it appears that after doing the POST, I don't get anything back. Interestingly, this is the behavior I would expect if I tried to make an HTTP connection on the HTTPS port (or visa versa), and I actually do get the same exact exception if I change the protocol. Everything I've looked at indicates that using "https://" in the URL is enough to enable SSL, but I'm starting wonder if I've missed something.

Note that Even though the credentials I'm using in the RPC are made up, I'm expecting to at least get back an XML error page (similar to if you access https://api.ultradns.net:8755/ with a web browser). I've tried running this code on OSX and Linux with the exact same result, so I have to conclude that I'm just doing something wrong here. Does anyone have any examples of doing XML-RPC over SSL with Ruby?


http://www.ultradns.net/api/NUS_API_XML.pdf explicitly states that the protocol is not compatible with standard XML-RPC clients. You need to add a toplevel transaction and session tag on top of method call.

<transaction>
  <methodCall>
     ...
  </methodCall>
</transaction>

So I guess the ruby xml-rpc parser is just not being able to parse the response. Just a theory. Have your tried other xml-rpc clients?

0

精彩评论

暂无评论...
验证码 换一张
取 消