Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > xmlrpc/clientライブラリ > XMLRPC::Clientクラス
クラスの継承リスト: XMLRPC::Client < Object < Kernel
Class XMLRPC::Client provides remote procedure calls to a XML-RPC server.
After setting the connection-parameters with [[unknown:XMLRPC::Client.new]] which creates a new XMLRPC::Client instance, you can execute a remote procedure by sending the XMLRPC::Client#call or XMLRPC::Client#call2 message to this new instance. The given parameters indicate which method to call on the remote-side and of course the parameters for the remote procedure.
require "xmlrpc/client" server = XMLRPC::Client.new("www.ruby-lang.org", "/RPC2", 80) begin param = server.call("michael.add", 4, 5) puts "4 + 5 = #{param}" rescue XMLRPC::FaultException => e puts "Error:" puts e.faultCode puts e.faultString end
or
require "xmlrpc/client" server = XMLRPC::Client.new("www.ruby-lang.org", "/RPC2", 80) ok, param = server.call2("michael.add", 4, 5) if ok then puts "4 + 5 = #{param}" else puts "Error:" puts param.faultCode puts param.faultString end
定義 | 説明 | |
---|---|---|
new(host=nil, path=nil, port=nil, proxy_host=nil, proxy_port=nil, user=nil, password=nil, use_ssl=false, timeout =nil)
|
Creates an object which represents the remote XML-RPC server on the given host host. If the server is CGI-based, path is the path to the CGI-script, which will be called, otherwise (in the case of a standalone server) path should be "/RPC2". port is the port on which the XML-RPC server listens. If proxy_host is given, then a proxy server listening at proxy_host is used. proxy_port is the port of the proxy server. |
|
new2(uri, proxy=nil, timeout=nil)
|
|
|
new3(hash={})
|
Parameter hash has following case-insensitive keys:
|
定義 | 説明 | |
---|---|---|
call(method, *args)
|
Invokes the method named method with the parameters given by args on the XML-RPC server. The parameter method is converted into a String and should be a valid XML-RPC method-name. Each parameter of args must be of one of the following types, where Hash, Struct and Array can contain any of these listed ((:types:)):
|
|
call2(method, *args)
|
The difference between this method and [[unknown:call|XMLRPC::Client#call]] is, that this method do ((*not*)) raise a XMLRPC::FaultException exception. The method returns an array of two values. The first value indicates if the second value is a return-value (true) or an object of type XMLRPC::FaultException. Both are explained in [[unknown:call|XMLRPC::Client#call]]. |
|
call_async(...)
|
In contrast to corresponding methods without "_async", these can be called concurrently and use for each request a new connection, where the non-asynchronous counterparts use connection-alive (one connection for all requests) if possible. |
|
cookie
|
Get and set the HTTP Cookie header. |
|
http_header_extra
|
Access the via [[unknown:XMLRPC::Client#http_header_extra=]] assigned header. |
|
http_header_extra=()
|
Set extra HTTP headers that are included in the request. |
|
http_last_response
|
Returns the Net::HTTPResponse object of the last RPC. |
|
multicall(*methods)
|
You can use this method to execute several methods on a XMLRPC server which supports the multi-call extension. Example: |
|
multicall2(*methods)
|
Same as [[unknown:XMLRPC::Client#multicall]], but returns like [[unknown:XMLRPC::Client#call2]] two parameters instead of raising an XMLRPC::FaultException. |
|
timeout
|
Return the corresponding attributes. |
|
timeout=()
|
Set the corresponding attributes. |
|
proxy(prefix, *args)
|
Returns an object of class XMLRPC::Client::Proxy, initialized with prefix and args. A proxy object returned by this method behaves like [[unknown:XMLRPC::Client#call]], i.e. a call on that object will raise a XMLRPC::FaultException when a fault-structure is returned by that call. |
|
proxy2(prefix, *args)
|
Almost the same like XMLRPC::Client#proxy only that a call on the returned XMLRPC::Client::Proxy object behaves like [[unknown:XMLRPC::Client#call2]], i.e. a call on that object will return two parameters. |
|
set_parser(parser)
|
Sets the XML parser to use for parsing XML documents. Should be an instance of a class from module XMLRPC::XMLParser. If this method is not called, then XMLRPC::Config::DEFAULT_PARSER is used. |
|
set_writer(writer)
|
Sets the XML writer to use for generating XML output. Should be an instance of a class from module XMLRPC::XMLWriter. If this method is not called, then XMLRPC::Config::DEFAULT_WRITER is used. |
==
===
=~
__id__
__send__
_dump
class
clone
dclone
display
enum_for
eql?
equal?
extend
freeze
frozen?
hash
initialize
initialize_copy
inspect
instance_eval
instance_exec
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
marshal_dump
marshal_load
method
method_missing
methods
nil?
pretty_inspect
pretty_print
pretty_print_cycle
pretty_print_inspect
pretty_print_instance_variables
private_methods
protected_methods
public_methods
remove_instance_variable
respond_to?
singleton_method_added
singleton_method_removed
singleton_method_undefined
singleton_methods
taint
tainted?
tap
to_a
to_ary
to_hash
to_int
to_io
to_proc
to_regexp
to_s
to_str
to_yaml
to_yaml_properties
to_yaml_style
untaint