# Xml-rpc calling question

**URL:** <https://www.ruby-forum.com/t/xml-rpc-calling-question/161657>\
**Category:** Ruby\
**Created:** [February 28, 2009, 3:01pm UTC](https://www.ruby-forum.com/t/xml-rpc-calling-question/161657 "2009-02-28T15:01:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 28, 2009, 3:01pm UTC](https://www.ruby-forum.com/t/xml-rpc-calling-question/161657/1 "2009-02-28T15:01:03Z")

</div>

I am trying to understand the XMLRPC client library and how to use it  
properly. I have looked at some of the examples and they area always  
add these two numbers together. I need help in writing a client with a  
complex structure of data, lots of individual values and arrays of  
values, even some structures.

Is there an example of how to create the passed structure a nd pass  
it. Or do I pass a hash of thelements?

Don F.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 28, 2009, 3:43pm UTC](https://www.ruby-forum.com/t/xml-rpc-calling-question/161657/2 "2009-02-28T15:43:54Z")

</div>

On Feb 28, 2009, at 7:59 AM, removed\_email\_address@domain.invalid wrote:

> I am trying to understand the XMLRPC client library and how to use it  
> properly. I have looked at some of the examples and they area always  
> add these two numbers together. I need help in writing a client with a  
> complex structure of data, lots of individual values and arrays of  
> values, even some structures.
> 
> Is there an example of how to create the passed structure a nd pass  
> it. Or do I pass a hash of thelements?

Arrays, Hashes, Numeric types, and simple Strings are all handled the  
same in XML-RPC. Just replace the simple data you’ve seen in the  
examples with more complex collections and it should work fine.

James Edward G. II

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 28, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/xml-rpc-calling-question/161657/3 "2009-02-28T17:27:19Z")

</div>

On Feb 28, 9:42 am, James G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Arrays, Hashes, Numeric types, and simple Strings are all handled the  
> same in XML-RPC. Just replace the simple data you’ve seen in the  
> examples with more complex collections and it should work fine.
> 
> James Edward G. II

Ok I have tried that with the following:  
server = XMLRPC::Client.new2(“[http://websearch.ramaui.com/ramxml.php](http://websearch.ramaui.com/ramxml.php)”)  
results = server.call(“lists”,{ “dbid” =\>“dbid1113086003”, “getlist”  
=\> “district”})

and I get XMLRPC::FaultException: XMLRPC::FaultException

Also tried this:  
results = server.call(“lists”,{ :dbid =\>“dbid1113086003”, :getlist =\>  
“district”})  
and same results

finally tried this:  
results = server.call(“lists”, :dbid =\>“dbid1113086003”, :getlist =\>  
“district”)

with the same results

I can run this as the base example I took it from:  
require ‘xmlrpc/client’  
require ‘pp’

server = XMLRPC::Client.new2(“[http://rpc.technorati.com/rpc/ping](http://rpc.technorati.com/rpc/ping)”)  
result = server.call(“weblogUpdates.ping”, “Copenhagen.rb”, “http://  
www.copenhagenrb.dk/”)  
pp result

And it woks fine.

What is the correct initialization and call?

## the actual xml structure that should be passed is this: lists
- - - - dbid - dbid1113086003 - getlist - district

When called from an unapproved ip it should come back with a message  
stating so.

Don F.  
Any ideas?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 1, 2009, 2:18am UTC](https://www.ruby-forum.com/t/xml-rpc-calling-question/161657/4 "2009-03-01T02:18:24Z")

</div>

On Feb 28, 2009, at 10:23 AM, removed\_email\_address@domain.invalid wrote:

> Ok I have tried that with the following:  
> server = XMLRPC::Client.new2(“[http://websearch.ramaui.com/ramxml.php](http://websearch.ramaui.com/ramxml.php)”)  
> results = server.call(“lists”,{ “dbid” =\>“dbid1113086003”, “getlist”  
> =\> “district”})

This looks right to me.

> the actual xml structure that should be passed is this:

> When called from an unapproved ip it should come back with a message  
> stating so.

They both seem to be what we are seeing:

$ ruby xtest.rb  
xtest.rb:7: warning: method redefined; discarding old call2

\<?xml version="1.0" ?\>lists\</

methodName\>getlist\</  
name\>district\</  
member\>dbiddbid1113086003\</  
string\>  
/usr/local/lib/ruby/1.8/xmlrpc/client.rb:414:in `call’: You do not  
have access to XML-RPC WebSearch. (XMLRPC::FaultException)  
Contact removed\_email\_address@domain.invalid if you have any questions.  
from xtest.rb:16  
$ cat xtest.rb  
#!/usr/bin/env ruby -wKU

require “xmlrpc/client”

# Patch XML-RPC to show us what is sent.

class XMLRPC::Client  
def call2(method, \*args)  
request = create().methodCall(method, \*args)  
puts request  
data = do\_rpc(request, false)  
parser().parseMethodResponse(data)  
end  
end

server = XMLRPC::Client.new2(“[http://websearch.ramaui.com/ramxml.php](http://websearch.ramaui.com/ramxml.php)”)  
results = server.call( “lists”, “dbid” =\> “dbid1113086003”,  
“getlist” =\> “district” )

**END**

What make you think this isn’t working?

James Edward G. II
