xml-rpc calling question

Discussion in 'Ruby' started by dhf0820.lists@gmail.com, Feb 28, 2009.

  1. Guest

    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 French
     
    , Feb 28, 2009
    #1
    1. Advertising

  2. James Gray Guest

    On Feb 28, 2009, at 7:59 AM, 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 Gray II
     
    James Gray, Feb 28, 2009
    #2
    1. Advertising

  3. Guest

    On Feb 28, 9:42 am, James Gray <> 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 Gray II


    Ok I have tried that with the following:
    server = XMLRPC::Client.new2("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")
    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:
    <methodCall>
    <methodName>lists</methodName>
    -
    <params>
    -
    <param>
    -
    <value>
    -
    <struct>
    -
    <member>
    <name>dbid</name>
    -
    <value>
    <string>dbid1113086003</string>
    </value>
    </member>
    -
    <member>
    <name>getlist</name>
    -
    <value>
    <string>district</string>
    </value>
    </member>
    </struct>
    </value>
    </param>
    </params>
    </methodCall>

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

    Don French
    Any ideas?
     
    , Feb 28, 2009
    #3
  4. James Gray Guest

    On Feb 28, 2009, at 10:23 AM, wrote:

    > Ok I have tried that with the following:
    > server = XMLRPC::Client.new2("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" ?><methodCall><methodName>lists</
    methodName><params><param><value><struct><member><name>getlist</
    name><value><string>district</string></value></
    member><member><name>dbid</name><value><string>dbid1113086003</
    string></value></member></struct></value></param></params></methodCall>
    /usr/local/lib/ruby/1.8/xmlrpc/client.rb:414:in `call': You do not
    have access to XML-RPC WebSearch. (XMLRPC::FaultException)
    Contact 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")
    results = server.call( "lists", "dbid" => "dbid1113086003",
    "getlist" => "district" )

    __END__

    What make you think this isn't working?

    James Edward Gray II
     
    James Gray, Mar 1, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pere Montolio

    XML RPC to ONC XDR RPC

    Pere Montolio, Aug 11, 2004, in forum: XML
    Replies:
    0
    Views:
    751
    Pere Montolio
    Aug 11, 2004
  2. Ymtrader
    Replies:
    1
    Views:
    602
    Adam Tauno Williams
    Mar 15, 2011
  3. Sven Schimmel

    Calling a XML-RPC-Service of phyton with vb.net

    Sven Schimmel, Sep 22, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    152
    Sven Schimmel
    Sep 22, 2004
  4. Shirish Joshi

    Ruby and Sun-RPC or ONC-RPC ?

    Shirish Joshi, Apr 7, 2004, in forum: Ruby
    Replies:
    0
    Views:
    217
    Shirish Joshi
    Apr 7, 2004
  5. Vladimir Konrad

    rpc (not xml-rpc)

    Vladimir Konrad, Sep 2, 2005, in forum: Ruby
    Replies:
    5
    Views:
    146
    Austin Ziegler
    Sep 3, 2005
Loading...

Share This Page