Check out
http://www.texperts.com/2007/12/21/using-action-web-service-with-rails-2
0/
if you are trying to get it to work on Rails 2.0
-----Original Message-----
From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of
MingMingTian
Sent: Wednesday, May 07, 2008 2:46 PM
To: Ruby on Rails: Talk
Subject: [Rails] Actionwebservice
I am just learning some about web service. But many guys still use
Java (Jws). But I wanna try ROR. There are less information about it.
I can''t get install plugin in the ROR 2.0.x. So I followed the
standard textbook("Agile_Web_Development_With_Rails-2nd" and
"Ruby on
Rails for PHP and Java Developers") I almost finished it. However, I
can''t find my api (http://localhost:3001/hello/api : GET not
supported). Anybody can help me? Many thanks.
I wanna invoke simple web service from client(3000) to Server(3001,
web service in)
I start localserver: http://localhost:3000/helloadmin
---------------------------------------------------
Hello Web Service
This rails application tests a web service.
Name:( )
Get Message
----------------------------------------------------
submit and get errors:
------------------------------------------------------------------------
------------
------------------------------------------------------------------------
------------
NameError in HelloadminController#getMsg_client
uninitialized constant HelloadminController::HelloApi
RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:477:in `const_missing''
#{RAILS_ROOT}/app/controllers/helloadmin_controller.rb:21:in
`getMsg_client''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:477:in `const_missing''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:1095:in `send''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:1095:in `perform_action_without_filters''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:632:in `call_filter''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:619:in `perform_action_without_benchmark''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue''
D:/InstantRails1.7/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/rescue.rb:83:in `perform_action''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `send''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `process_without_filters''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:624:in
`process_without_session_management_support''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/session_management.rb:114:in `process''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:330:in `process''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
dispatcher.rb:41:in `dispatch''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/rails.rb:78:in `process''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/rails.rb:76:in `synchronize''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/rails.rb:76:in `process''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:618:in `process_client''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:617:in `each''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:617:in `process_client''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `initialize''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `new''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:720:in `initialize''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:720:in `new''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:720:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/configurator.rb:271:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/configurator.rb:270:in `each''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/configurator.rb:270:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
bin/mongrel_rails:127:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/command.rb:211:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
bin/mongrel_rails:243
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:488:in `load''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:488:in `load''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:342:in `new_constants_in''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:488:in `load''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
commands/servers/mongrel.rb:60
D:/InstantRails1.7/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `gem_original_require''
D:/InstantRails1.7/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `require''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:495:in `require''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:342:in `new_constants_in''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:495:in `require''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
commands/server.rb:39
D:/InstantRails1.7/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `gem_original_require''
D:/InstantRails1.7/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `require''
script/server:3
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:477:in `const_missing''
#{RAILS_ROOT}/app/controllers/helloadmin_controller.rb:21:in
`getMsg_client''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:1095:in `send''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:1095:in `perform_action_without_filters''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:632:in `call_filter''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:619:in `perform_action_without_benchmark''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue''
D:/InstantRails1.7/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/rescue.rb:83:in `perform_action''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `send''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `process_without_filters''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:624:in
`process_without_session_management_support''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/session_management.rb:114:in `process''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:330:in `process''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
dispatcher.rb:41:in `dispatch''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/rails.rb:78:in `process''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/rails.rb:76:in `synchronize''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/rails.rb:76:in `process''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:618:in `process_client''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:617:in `each''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:617:in `process_client''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `initialize''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `new''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:720:in `initialize''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:720:in `new''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:720:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/configurator.rb:271:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/configurator.rb:270:in `each''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/configurator.rb:270:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
bin/mongrel_rails:127:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/command.rb:211:in `run''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
bin/mongrel_rails:243
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:488:in `load''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:488:in `load''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:342:in `new_constants_in''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:488:in `load''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
commands/servers/mongrel.rb:60
D:/InstantRails1.7/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `gem_original_require''
D:/InstantRails1.7/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `require''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:495:in `require''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:342:in `new_constants_in''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/
active_support/dependencies.rb:495:in `require''
D:/InstantRails1.7/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
commands/server.rb:39
D:/InstantRails1.7/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `gem_original_require''
D:/InstantRails1.7/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `require''
script/server:3
Request
Parameters: {"name"=>["ww"],
"commit"=>"Get Message"}
Show session dump
---
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers: {"cookie"=>[],
"Cache-Control"=>"no-cache"}
------------------------------------------------------------------------
---------
------------------------------------------------------------------------
---------
My codes:
helloservice:
helloservice\app\apis:
class HelloApi < ActionWebService::API::Base
api_method :getMsg,
:expects => [{:name => :string}],
:returns => [[:string]]
end
helloservice\app\controllers
class HelloController < ApplicationController
wsdl_service_name ''Hello''
web_service_api HelloApi
web_service_scaffold :invoke
def getMsg(name)
"Hello "+ name
end
end
helloadmin:
helloadmin\app\controllers
class HelloadminController < ApplicationController
def getMsg_client
hello_client = ActionWebService::Client::Soap.new(HelloApi,
"http://localhost:3001/hello/api")
@service_output = hello_client.getMsg(params[:name])
end
end
helloadmin\app\views\helloadmin
index.rhtml:
<html>
<head>
<title>Hello Web Service</title>
</head>
<body>
<h1>Hello Web Service</h1>
<p>
This rails application tests a web service.
</p>
<%= start_form_tag :action=> ''getMsg_client'' %>
<p><label>Name</label><br/>
<%= text_field ''name'', ''''
%></p>
<%= submit_tag "Get Message" %>
<%= end_form_tag %>
</body>
</html>
getMsg.rhtml:
<html>
<head>
<title>Hello Web Service</title>
</head>
<body>
</p>
<p><%= @service_output %></p>
</body>
</html>
I don''t understand why it is not working!!!
Ming
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---