Class: XML::XMLRPC::Client
- Inherits:
-
Object
- Object
- XML::XMLRPC::Client
- Defined in:
- lib/xml/libxml/xmlrpc/client.rb
Overview
Client is an easy-to-use XML-RPC method call and response mechanism.
It will not handle redirection.
Instance Method Summary collapse
-
#call(methodName, *args) ⇒ Object
Call and recieve the response.
-
#initialize(http, url) ⇒ Client
constructor
Given an unused Net::HTTP object and a relative URL, it will post the XML-RPC information to this form after calling a method with ruby types.
-
#method_missing(*args) ⇒ Object
See #call.
Constructor Details
#initialize(http, url) ⇒ Client
Given an unused Net::HTTP object and a relative URL, it will post the XML-RPC information to this form after calling a method with ruby types.
See XML::XMLRPC::Builder for caveats related to Base64 handling.
19 20 21 22 |
# File 'lib/xml/libxml/xmlrpc/client.rb', line 19 def initialize(http, url) @http = http @url = url end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
See #call.
27 28 29 |
# File 'lib/xml/libxml/xmlrpc/client.rb', line 27 def method_missing(*args) self.call(*args) end |
Instance Method Details
#call(methodName, *args) ⇒ Object
Call and recieve the response. Returns a XML::XMLRPC::Parser object.
Will throw an XML::XMLRPC::RemoteCallError if the call returns a fault response.
37 38 39 40 41 |
# File 'lib/xml/libxml/xmlrpc/client.rb', line 37 def call(methodName, *args) res = @http.post(@url, XML::XMLRPC::Builder.call(methodName, *args)) res_args = XML::XMLRPC::Parser.new(res.body) return res_args end |