Getting an array back in xmlrpc?

G

gregarican

I started off passing back a single SQL record to my xmlrpc client
using the following code on the xmlrpc server:

resultSet = query.fetch.to_a
return resultSet

Now I am looking to pass along an SQL recordset to my xmlrpc client. So
I tried the following code on the xmlrpc server:

resultSet = query.fetch_all.to_a
return resultSet

But the xmlrpc client end reports an HTTP 500 Internal Server error
when parsing this SQL recordset data back. I am using code like the
following on the xmlrpc client:

resultSet.collect {|line|
puts line
}

What should I do on the xmlrpc client end to correctly interpret the
results? When I print them to the console on the xmlrpc server I can
tell the SQL recordset is being passed back to the xmlrpc client as a
two dimensional array...
 
P

Pit Capitain

gregarican said:
I started off passing back a single SQL record to my xmlrpc client
using the following code on the xmlrpc server:

resultSet = query.fetch.to_a
return resultSet

Now I am looking to pass along an SQL recordset to my xmlrpc client. So
I tried the following code on the xmlrpc server:

resultSet = query.fetch_all.to_a
return resultSet

But the xmlrpc client end reports an HTTP 500 Internal Server error
when parsing this SQL recordset data back.

If this works

query.fetch.to_a

and this doesn't

query.fetch_all.to_a

maybe you need to convert each single record to an array first, like

query.fetch_all.map { |record| record.to_a }

Just a guess...

Regards,
Pit
 
G

gregarican

Pit said:
If this works

query.fetch.to_a


and this doesn't


query.fetch_all.to_a


maybe you need to convert each single record to an array first, like


query.fetch_all.map { |record| record.to_a }


Just a guess...


Regards,
Pit

Digging deeper into the docs I see that xmlrpc can only handle a one
dimensional array being passed back to the client. So what I did was
pass back string values with ';' row delimiters and ',' record
delimiters. Then the client parses this out to in turn shuffle them
into the two-dimensional array I was looking for. The code is too ugly
to post here due to my clumsiness :) but it works!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top