From fdecb6843ba8c5b0f718225f343017e11fa7f711 Mon Sep 17 00:00:00 2001 From: Leon Breedt Date: Fri, 18 Feb 2005 21:22:52 +0000 Subject: rename service* to web_service*. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@668 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionservice/examples/googlesearch/README | 28 ++++-------- .../delegated/google_search_service.rb | 4 +- .../googlesearch/delegated/search_controller.rb | 4 +- .../googlesearch/direct/google_search_api.rb | 50 ++++++++++++++++++++ .../googlesearch/direct/search_controller.rb | 53 +--------------------- .../examples/metaWeblog/blog_controller.rb | 32 +++++++------ 6 files changed, 83 insertions(+), 88 deletions(-) create mode 100644 actionservice/examples/googlesearch/direct/google_search_api.rb (limited to 'actionservice/examples') diff --git a/actionservice/examples/googlesearch/README b/actionservice/examples/googlesearch/README index 20ecbc3a76..25ccbd2382 100644 --- a/actionservice/examples/googlesearch/README +++ b/actionservice/examples/googlesearch/README @@ -1,6 +1,5 @@ = Google Service example - This example shows how one would implement an API like Google Search that uses lots of structured types. @@ -9,26 +8,19 @@ modes. There is also an example for API definition file autoloading. -= Running - - 1. Ensure you have the 'actionservice' Gem installed. You can generate it using - this command: - - $ rake package - - - 2. Edit config/environment.rb, and add the following line after the rest of the - require_gem statements: - require_gem 'actionservice' += Running the examples + 1. Add the files to an Action Web Service enabled Rails project. - 3. "Direct" example: + "Direct" example: * Copy direct/search_controller.rb to "app/controllers" in a Rails project. + * Copy direct/google_search_api.rb to "app/apis" + in a Rails project - "Delegated" example: + "Delegated" example: * Copy delegated/search_controller.rb to "app/controllers" in a Rails project. @@ -44,7 +36,7 @@ There is also an example for API definition file autoloading. in a Rails project. - 4. Go to the WSDL url in a browser, and check that it looks correct. + 2. Go to the WSDL url in a browser, and check that it looks correct. "Direct" and "Delegated" examples: http://url_to_project/search/wsdl @@ -60,7 +52,7 @@ There is also an example for API definition file autoloading. explain extreme similarities :) - 5. Test that it works with .NET (Mono in this example): + 3. Test that it works with .NET (Mono in this example): $ wget WSDL_URL $ mv wsdl GoogleSearch.wsdl @@ -144,8 +136,8 @@ There is also an example for API definition file autoloading. If you don't like this behaviour, you can do: class MyController < ActionController::Base - service_exception_reporting false + web_service_exception_reporting false end - 6. Crack open a beer. Publishing APIs for working with the same model as + 4. Crack open a beer. Publishing APIs for working with the same model as your Rails web app should be easy from now on :) diff --git a/actionservice/examples/googlesearch/delegated/google_search_service.rb b/actionservice/examples/googlesearch/delegated/google_search_service.rb index 84faf220ae..da7f8f4529 100644 --- a/actionservice/examples/googlesearch/delegated/google_search_service.rb +++ b/actionservice/examples/googlesearch/delegated/google_search_service.rb @@ -1,5 +1,3 @@ -require 'action_service' - class DirectoryCategory < ActionService::Struct member :fullViewableName, :string member :specialEncoding, :string @@ -52,7 +50,7 @@ class GoogleSearchAPI < ActionService::API::Base end class GoogleSearchService < ActionService::Base - service_api GoogleSearchAPI + web_service_api GoogleSearchAPI def doGetCachedPage(key, url) "i am a cached page" diff --git a/actionservice/examples/googlesearch/delegated/search_controller.rb b/actionservice/examples/googlesearch/delegated/search_controller.rb index 58c8321ef2..6525921b5a 100644 --- a/actionservice/examples/googlesearch/delegated/search_controller.rb +++ b/actionservice/examples/googlesearch/delegated/search_controller.rb @@ -2,6 +2,6 @@ require 'google_search_service' class SearchController < ApplicationController wsdl_service_name 'GoogleSearch' - service_dispatching_mode :delegated - service :beta3, GoogleSearchService.new + web_service_dispatching_mode :delegated + web_service :beta3, GoogleSearchService.new end diff --git a/actionservice/examples/googlesearch/direct/google_search_api.rb b/actionservice/examples/googlesearch/direct/google_search_api.rb new file mode 100644 index 0000000000..e7e33a1105 --- /dev/null +++ b/actionservice/examples/googlesearch/direct/google_search_api.rb @@ -0,0 +1,50 @@ +class DirectoryCategory < ActionService::Struct + member :fullViewableName, :string + member :specialEncoding, :string +end + +class ResultElement < ActionService::Struct + member :summary, :string + member :URL, :string + member :snippet, :string + member :title, :string + member :cachedSize, :string + member :relatedInformationPresent, :bool + member :hostName, :string + member :directoryCategory, DirectoryCategory + member :directoryTitle, :string +end + +class GoogleSearchResult < ActionService::Struct + member :documentFiltering, :bool + member :searchComments, :string + member :estimatedTotalResultsCount, :int + member :estimateIsExact, :bool + member :resultElements, [ResultElement] + member :searchQuery, :string + member :startIndex, :int + member :endIndex, :int + member :searchTips, :string + member :directoryCategories, [DirectoryCategory] + member :searchTime, :float +end + +class GoogleSearchAPI < ActionService::API::Base + inflect_names false + + api_method :doGetCachedPage, :returns => [:string], :expects => [{:key=>:string}, {:url=>:string}] + api_method :doGetSpellingSuggestion, :returns => [:string], :expects => [{:key=>:string}, {:phrase=>:string}] + + api_method :doGoogleSearch, :returns => [GoogleSearchResult], :expects => [ + {:key=>:string}, + {:q=>:string}, + {:start=>:int}, + {:maxResults=>:int}, + {:filter=>:bool}, + {:restrict=>:string}, + {:safeSearch=>:bool}, + {:lr=>:string}, + {:ie=>:string}, + {:oe=>:string} + ] +end diff --git a/actionservice/examples/googlesearch/direct/search_controller.rb b/actionservice/examples/googlesearch/direct/search_controller.rb index e4e1d7a0eb..7c69f0225e 100644 --- a/actionservice/examples/googlesearch/direct/search_controller.rb +++ b/actionservice/examples/googlesearch/direct/search_controller.rb @@ -1,56 +1,5 @@ -class DirectoryCategory < ActionService::Struct - member :fullViewableName, :string - member :specialEncoding, :string -end - -class ResultElement < ActionService::Struct - member :summary, :string - member :URL, :string - member :snippet, :string - member :title, :string - member :cachedSize, :string - member :relatedInformationPresent, :bool - member :hostName, :string - member :directoryCategory, DirectoryCategory - member :directoryTitle, :string -end - -class GoogleSearchResult < ActionService::Struct - member :documentFiltering, :bool - member :searchComments, :string - member :estimatedTotalResultsCount, :int - member :estimateIsExact, :bool - member :resultElements, [ResultElement] - member :searchQuery, :string - member :startIndex, :int - member :endIndex, :int - member :searchTips, :string - member :directoryCategories, [DirectoryCategory] - member :searchTime, :float -end - -class GoogleSearchAPI < ActionService::API::Base - inflect_names false - - api_method :doGetCachedPage, :returns => [:string], :expects => [{:key=>:string}, {:url=>:string}] - api_method :doGetSpellingSuggestion, :returns => [:string], :expects => [{:key=>:string}, {:phrase=>:string}] - - api_method :doGoogleSearch, :returns => [GoogleSearchResult], :expects => [ - {:key=>:string}, - {:q=>:string}, - {:start=>:int}, - {:maxResults=>:int}, - {:filter=>:bool}, - {:restrict=>:string}, - {:safeSearch=>:bool}, - {:lr=>:string}, - {:ie=>:string}, - {:oe=>:string} - ] -end - class SearchController < ApplicationController - service_api GoogleSearchAPI + web_service_api :google_search wsdl_service_name 'GoogleSearch' def doGetCachedPage diff --git a/actionservice/examples/metaWeblog/blog_controller.rb b/actionservice/examples/metaWeblog/blog_controller.rb index b23ccb04c6..aff2e909ea 100644 --- a/actionservice/examples/metaWeblog/blog_controller.rb +++ b/actionservice/examples/metaWeblog/blog_controller.rb @@ -1,3 +1,6 @@ +# point your client at http://project_url/blog/api to test +# this + # structures as defined by the metaWeblog/blogger # specifications. module Blog @@ -73,7 +76,7 @@ class MetaWeblogAPI < ActionService::API::Base end class BlogController < ApplicationController - service_api MetaWeblogAPI + web_service_api MetaWeblogAPI def initialize @postid = 0 @@ -99,23 +102,26 @@ class BlogController < ApplicationController def getUsersBlogs $stderr.puts "Returning user %s's blogs" % @params['username'] - blog = Blog::Blog.new - blog.url = 'http://blog.xeraph.org' - blog.blogid = 'sttm' - blog.blogName = 'slave to the machine' + blog = Blog::Blog.new( + :url =>'http://blog.xeraph.org', + :blogid => 'sttm', + :blogName => 'slave to the machine' + ) [blog] end def getRecentPosts $stderr.puts "Returning recent posts (%d requested)" % @params['numberOfPosts'] - post1 = Blog::Post.new - post1.title = 'first post!' - post1.link = 'http://blog.xeraph.org/testOne.html' - post1.description = 'this is the first post' - post2 = Blog::Post.new - post2.title = 'second post!' - post2.link = 'http://blog.xeraph.org/testTwo.html' - post2.description = 'this is the second post' + post1 = Blog::Post.new( + :title => 'first post!', + :link => 'http://blog.xeraph.org/testOne.html', + :description => 'this is the first post' + ) + post2 = Blog::Post.new( + :title => 'second post!', + :link => 'http://blog.xeraph.org/testTwo.html', + :description => 'this is the second post' + ) [post1, post2] end end -- cgit v1.2.3