Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
wkoffel committed Jan 1, 2010
1 parent 1b104d0 commit 374cd38
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doc/created.rid
@@ -1 +1 @@
Fri, 01 Jan 2010 15:19:07 -0500
Fri, 01 Jan 2010 16:09:53 -0500
65 changes: 50 additions & 15 deletions doc/files/README_rdoc.html
Expand Up @@ -56,7 +56,7 @@ <h1>README.rdoc</h1>
</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>
Expand All @@ -77,37 +77,72 @@ <h1>xmlrpc-endpoint</h1>
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 &quot;xmlrpc-endpoint&quot; (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

</li>
<li>include ActionController::Acts::XmlrpcEndpoint somewhere in your
environment

</li>
<li>set up a route to the action &quot;index&quot; in your controller (this
action will be created for you by the xmlrpc-endpoint)
<pre>
# set up a route to the action &quot;xe_index&quot; in your controller
# (this &quot;xe_index&quot; 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>
</ul>
map.connect 'api/xmlrpc', :controller =&gt; 'my_api_controller', :action =&gt; 'xe_index'
</pre>
<p>
Add this code to your controller:
</p>
<pre>
class MyApiController &lt; ApplicationController
exposes_xmlrpc_methods

def hello_world
puts &quot;Hello XMLRPC.&quot;
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(&quot;http://localhost:3000/api/xmlrpc&quot;)
server.call(&quot;hello_world&quot;)
</pre>
<p>
To use a custom namespace prefix on all exposed methods (for example, if
using someone else&#8216;s specified protocol like <a
href="http://www.xmlrpc.com/metaWeblogApi">MetaWeblog</a>), declare a
method_prefix:
</p>
<pre>
class MyApiController &lt; ApplicationController
exposes_xmlrpc_methods :method_prefix =&gt; &quot;metaWeblog.&quot;

# This method will be exposed externally as &quot;metaWeblog.newPost()&quot;
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.
Expand Down

0 comments on commit 374cd38

Please sign in to comment.