続・Rails1.2.1+GetText1.9.0
やっぱりどうもGetTextを組み込むとActionWebServiceで作ったXML-RPC APIがおかしくなるみたい。
実験内容
環境は次の通りです。
- Mac OS X 10.4.8
- ruby 1.8.5 (2006-08-25) [powerpc-darwin8.8.0]
- Rails 1.2.1
- Ruby-GetText-Package 1.9.0
新規Railsアプリケーションを生成。
$ rails xmlrpctest
ごく簡単なXML-RPC APIを実装する
app/apis/xmlrpc_api.rb
class XmlrpcApi < ActionWebService::API::Base inflect_names false api_method :echo, :returns => [:string], :expects => [{:params => :string}] end class XmlrpcService < ActionWebService::Base web_service_api XmlrpcApi def echo(params) return params end end
app/controllers/xmlrpc_controller.rb
class XmlrpcController < ApplicationController layout nil web_service_dispatching_mode :delegated web_service :api, XmlrpcService.new web_service_scaffold :invoke end
これを起動して、irbで叩いてみる。
$ irb irb(main):001:0> require 'xmlrpc/client' => true irb(main):002:0> sv = XMLRPC::Client.new2('http://localhost:3000/xmlrpc/api') => #<XMLRPC::Client:0x584fa8 @proxy_port=nil, @auth=nil, @cookie=nil, @create=nil, @port=3000, @http=#<Net::HTTP localhost:3000 open=false>, @proxy_host=nil, @http_last_response=nil, @parser=nil, @timeout=30, @path="/xmlrpc/api", @password=nil, @http_header_extra=nil, @use_ssl=false, @host="localhost", @user=nil> irb(main):003:0> sv.call('echo', 'hoge') => "hoge"
正常動作。
GetTextを組み込む。
config/environment.rbの末尾に以下のコードを追記
require 'gettext/rails'
app/controllres/application.rbを修正
class ApplicationController < ActionController::Base session :session_key => '_xmlrpctest_session_id' init_gettext "xmlrpc"#この行を追加 end
再起動してirbから叩いてみる。
irb(main):006:0> sv.call('echo', 'hoge') RuntimeError: HTTP-Error: 500 Internal Server Error from /opt/local/lib/ruby/1.8/xmlrpc/client.rb:546:in `do_rpc' from /opt/local/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2' from /opt/local/lib/ruby/1.8/xmlrpc/client.rb:410:in `call' from (irb):6 from /opt/local/lib/ruby/1.8/date.rb:652
落ちた。
この状態のサンプルアプリケーションを置いておきます。何か解決法があれば教えてください。