Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > xmlrpcライブラリ

library xmlrpc


XML-RPC を扱うためのライブラリです。

このページは xmlrpc ライブラリのまとめのページであり、require 'xmlrpc' を実行しても エラーになることに注意して下さい。

Author and Copyright

Copyright (C) 2001-2004 by Michael Neumann

Released under the same term of license as Ruby.


XMLRPC is a lightweight protocol that enables remote procedure calls over HTTP. It is defined at

XMLRPC allows you to create simple distributed computing solutions that span computer languages. Its distinctive feature is its simplicity compared to other approaches like SOAP and CORBA.

The Ruby standard library package 'xmlrpc' enables you to create a server that implements remote procedures and a client that calls them. Very little code is required to achieve either of these.


Try the following code. It calls a standard demonstration remote procedure.

require 'xmlrpc/client'
require 'pp'

server = XMLRPC::Client.new2("")
result ="sample.sumAndDifference", 5, 3)
pp result


See There is plenty of detail there to use the client and implement a server.

Features of XMLRPC for Ruby

* Extensions

* Server

* Client

* Parsers

* General

Choosing a different XML Parser or XML Writer

The examples above all use the default parser (which is now since 1.8 REXMLStreamParser) and a default XML writer. If you want to use a different XML parser, then you have to call the <i>set_parser</i> method of XMLRPC::Client instances or instances of subclasses of XMLRPC::BasicServer or by editing xmlrpc/config.rb.

Client Example:

# ...
server = "", "/api/sample.php")
# ...

Server Example:

# ...
s =
# ...


# ...
server =
# ...

Note that XMLStreamParser is incredible faster (and uses less memory) than any other parser and scales well for large documents. For example for a 0.5 MB XML document with many tags, XMLStreamParser is ~350 (!) times faster than NQXMLTreeParser and still ~18 times as fast as XMLTreeParser.

You can change the XML-writer by calling method <i>set_writer</i>.




XML-RPC クライアントのためのライブラリです。


XML-RPC サーバのためのライブラリです。