Re: XMLRPC Question

So what I entered into telnet was just:

That definitely isn’t XMLRPC. The XMLRPC spec is very simple, see
http://www.xmlrpc.com/spec

Since the root element isn’t then it isn’t XMLRPC, so you
won’t
be able to use an xmlrpc client library.

What you seem to have is an ad-hoc XML-over-TCP exchange. So you need
to:

(1) Open a TCPSocket to connect to the server
(2) Squirt your XML request down it
(3) Perhaps: half-close the connection (*)
(4) Read the response
(5) Either wait for the connection to close, or wait for the closing tag
of the response (**)

(*) This depends on how the server detects the end of the request - does
it
look for the closing tag, or does it wait for the connection to close?

(**) The first case lets you read a blob and parse it afterwards. The
second
requires you to parse as you read, e.g. with a stream parser.

If the server side closes the connection after sending the response, you
might be able to start with something as simple as

require ‘socket’
conn = TCPSocket.new(‘1.2.3.4’, 1234) # Destination hostname and port
conn.puts “”
#conn.close_write # maybe not needed
res = conn.read
conn.close
puts res

Then pass res to a parser like REXML. If not, then you should pass the
open
conn object to something like an REXML StreamParser to read element at a
time.

You’ll just have to play with it to make it work, or talk to the server
designer, since there are some unknowns in the above. If they were using
XML-over-HTTP then it would be clearer, because the semantics of
end-of-request and end-of-response for HTTP are well-defined.

HTH,

Brian.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs