doc/files/README_rdoc.html in xmlrpc-endpoint-0.1.1 vs doc/files/README_rdoc.html in xmlrpc-endpoint-0.2.0
- old
+ new
@@ -54,11 +54,11 @@
<td>README.rdoc
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Fri Jan 01 15:19:02 -0500 2010</td>
+ <td>Fri Jan 01 16:09:48 -0500 2010</td>
</tr>
</table>
</div>
<!-- banner header -->
@@ -75,39 +75,74 @@
‘xmlrpc/client’ library. The ‘xmlrpc/server’
library examples mostly make an assumption that you will run a standalone
server.
</p>
<p>
-xmlrpc-endpoint allows you to expose normal Rails controller methods via
-XMLRPC, tied to a single xmlrpc endpoint route in your normal app.
+xmlrpc-endpoint allows you to instead expose normal Rails controller
+methods via XMLRPC, tied to an xmlrpc endpoint route in your app.
</p>
<p>
+Install
+</p>
+<pre>
+ gem install xmlrpc-endpoint
+ config.gem "xmlrpc-endpoint" (inside environment.rb Rails::Initializer block)
+ -- OR --
+ ./script/plugin install git://github.com/wkoffel/xmlrpc-endpoint.git
+</pre>
+<p>
Setup your environment
</p>
-<ul>
-<li>gem install xmlrpc-endpoint
+<pre>
+ # set up a route to the action "xe_index" in your controller
+ # (this "xe_index" action will be created for you by the xmlrpc-endpoint, the route must point at 'xe_index' action to work)
+ # In a future release, xmlrpc-endpoint may support auto-generation of this route, and customization
-</li>
-<li>include ActionController::Acts::XmlrpcEndpoint somewhere in your
-environment
-
-</li>
-<li>set up a route to the action "index" in your controller (this
-action will be created for you by the xmlrpc-endpoint)
-
-</li>
-</ul>
+ map.connect 'api/xmlrpc', :controller => 'my_api_controller', :action => 'xe_index'
+</pre>
<p>
Add this code to your controller:
</p>
<pre>
class MyApiController < ApplicationController
exposes_xmlrpc_methods
+
+ def hello_world
+ puts "Hello XMLRPC."
+ end
end
</pre>
<p>
Then, pointing an XMLRPC client at the defined route, your normal
controller actions will handle the requests.
+</p>
+<pre>
+ require 'xmlrpc/client'
+ server = XMLRPC::Client.new2("http://localhost:3000/api/xmlrpc")
+ server.call("hello_world")
+</pre>
+<p>
+To use a custom namespace prefix on all exposed methods (for example, if
+using someone else‘s specified protocol like <a
+href="http://www.xmlrpc.com/metaWeblogApi">MetaWeblog</a>), declare a
+method_prefix:
+</p>
+<pre>
+ class MyApiController < ApplicationController
+ exposes_xmlrpc_methods :method_prefix => "metaWeblog."
+
+ # This method will be exposed externally as "metaWeblog.newPost()"
+ def newPost(blogid, username, password, struct, publish)
+ ...
+ end
+
+ etc.
+ end
+</pre>
+<p>
+Thanks to Nathan Crause for saving me some time on the details of avoiding
+the standalone server. <a
+href="http://nathan.crause.name/entries/programming/xlm-rpc-under-ruby-on-rails">nathan.crause.name/entries/programming/xlm-rpc-under-ruby-on-rails</a>
</p>
<h2>Note on Patches/Pull Requests</h2>
<ul>
<li>Fork the project.
\ No newline at end of file