Tuesday, November 17, 2009

Action Web Service Gem

hi i am using 'actionwebservice' for passing SOAP requests.

Version 2.3.2 for actionwebservice is " datanoise-actionwebservice"

For installing the gem when i used,

gem install datanoise-actionwebservice

got this error,
ERROR: could not find gem datanoise-actionwebservice locally or in a repository

& found this is the right way to install

gem install datanoise-actionwebservice --source http://gems.github.com


Add this line to your config/environment.rb file in the initializer section:

config.gem 'datanoise-actionwebservice', :lib => 'actionwebservice'


Generating API controller

ActionWebService gem includes web_service generator that you can use like this:

$ ./script/generate web_service post


Define your API

Open app/services/post_api.rb file and add methods that your service exposes:

class PostApi < returns =""> [[:string]]
end


API implementation

We are going to use direct dispatching mode, so all methods that implement our API go directly to PostController itself:

class PostController < ApplicationController wsdl_service_name 'Post' web_service_api PostApi web_service_scaffold :invocation if Rails.env == 'development' def get_posts ["Post 1", "Post 2"] end end wsdl url:
http://localhost:3000/post/wsdl



Books : Restful Web Services | Web Services Essentials (O'Reilly XML) | Web Services: Principles and Technology | RESTful Web Services Cookbook

7 comments:

Minal Jain said...

hi.. Srikanth..
I go thru ur blog but I got error after this step------
Add this line to your config/environment.rb file in the initializer section:

config.gem 'datanoise-actionwebservice', :lib => 'actionwebservice'


Server cant start and gives the follwoing error....

Exiting

C:/ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:300:in `match': can't convert Hash into String (TypeError)

from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:300:in `parse'

from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:238:in `initialize'

-------- If possible pls help.. its urgent..


Also if I wrote require 'datanoise-actionwebservice' on irb

it says no such file to load !!
Thanks

Minal

Srikanth Jeeva said...

After installing the gem, Have you restarted your server?

Minal Jain said...

yess....
wat to do next ?

Srikanth Jeeva said...

check if the gem version is 2.3.2 .. If so, i'm not sure why this error occurs.

Srikanth Jeeva said...

i have used this long back and it worked for me that time. Might be gem and ruby versions problem, not sure abt it. Now i'm using Restful Webservice.

Minal Jain said...

okies.. :(

hav u write any blog on restful webservice

Srikanth Jeeva said...

I have worked many projects with Restful Webservices, but haven't made a post yet. I have searched and i got it, I do similar as given in this post.

http://weblog.jamisbuck.org/2006/3/27/web-services-rails-style

Any more clarifications abt restful mail me @ sri.jjhero@gmail.com