Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Rails] Problem with implementing a XML-RPC handler
- From: woeye at mac.com (Lars Hoss)
- Subject: [Rails] Problem with implementing a XML-RPC handler
- Date: Tue Jan 18 13:12:16 2005
Hi all!
I am currently implementing support for the MovableType API in my Rails
based weblog engine (known as RubyTwaddle). For now the XML-RPC
invocations are handled by a special controller:
class XmlrpcController < ApplicationController
model :weblog
def initialize
@server = XMLRPC::BasicServer.new
@server.add_handler("metaWeblog", MetaWeblogAPI.new)
end
def index
xmlData = @params.to_a[0].to_s
logger.info("xml-requst: #{xmlData}")
begin
xmlResponse = @server.process(xmlData)
rescue Exception => error
logger.info("error: #{error}")
end
@headers["Content-Type"] = "text/xml"
logger.info("xml-response: #{xmlResponse}")
render_text(xmlResponse)
end
end
Though most of the time this approach works fairly well there's still a
major problem. In order to get the XML sequence of the XML-RPC
invocation I convert the params hash into an array, fetch the first
element and convert it into a string. I have to convert it into an
array because the the xml sequence of the XML-RPC invocation is the key
in hash and has no value.
Now the problem is that Rails automatically formats all request
parameters. For example something like
"&foo+moo=this+is+a+string+with+spaces" will become @params["foo moo"]
= "This is a string with spaces". This is of course the correct
behaviour. In my case, however, this means that all "+" characters in
the XML sequence gets converted into " " characters. And this affects
embedded base64 encoded data as well. Therefore it is not possible to
decode this base64 data back.
I guess that a controller for processing the XML-RPC invocation isn't a
good approach for a controller seems to be more focused on regular HTTP
browser requests. What I need is a way to get access to the raw request
data. Any suggestions? :-)
Regards,
Lars
--
"Stil ist die F?higkeit, komplizierte Dinge einfach zu sagen - nicht
umgekehrt." -- Cocteau, Jean
- Follow-Ups:
- Prev by Date: [Rails] [ANN] Rails 0.9.4: Caching, filters, SQLite3?
- Next by Date: [Rails] [ANN] Rails 0.9.4: Caching, filters, SQLite3?
- Previous by thread: [Rails] text_field and hidden_field don't work in a for loop?
- Next by thread: [Rails] Problem with implementing a XML-RPC handler
- Index(es):