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.
Class Method Summary collapse
-
.debug ⇒ Object
get the debug state.
-
.debug=(x) ⇒ Object
set the debug state.
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.
30 31 32 33 |
# File 'lib/xml/libxml/xmlrpc/client.rb', line 30 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.
38 39 40 |
# File 'lib/xml/libxml/xmlrpc/client.rb', line 38 def method_missing(*args) self.call(*args) end |
Class Method Details
.debug ⇒ Object
get the debug state
19 20 21 |
# File 'lib/xml/libxml/xmlrpc/client.rb', line 19 def self.debug @debug end |
.debug=(x) ⇒ Object
set the debug state
14 15 16 |
# File 'lib/xml/libxml/xmlrpc/client.rb', line 14 def self.debug=(x) @debug = x 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.
48 49 50 51 52 53 54 55 |
# File 'lib/xml/libxml/xmlrpc/client.rb', line 48 def call(methodName, *args) XML::XMLRPC::Builder.debug = self.class.debug XML::XMLRPC::Parser.debug = self.class.debug res = @http.post(@url, XML::XMLRPC::Builder.call(methodName, *args), { "Content-type" => 'text/xml' }) res_args = XML::XMLRPC::Parser.new(res.body) return res_args end |