Hi all, I try to create a RoR app to consume a RESTFul WCF service. I used WebInvoke to wrap WCF service then launched it by using Visual studio using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; using System.ServiceModel.Web; namespace WCF_REST { [ServiceContract] public interface IRestServiceImpl { [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "{id}")] string XMLData(string id); [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/{id}")] string JSONData(string id); } } So type http://localhost:50173/RestServiceImpl.svc/json/1999999999999999 in the browser, it will return a json file on screen. Then I created a RoR app trying to consumer this WCF service the controller class: require ''active_resource'' class ServiceController < ApplicationController def show @wcf_service = RestServiceImpl.find(1) end end class RestServiceImpl < ActiveResource::Base self.site = "http://localhost:50173/" end View: <h1>Hello Ruby!</h1> <p> <%= @wcf_service %> </p> Then I launched the RoR app on rubymine built in server WEBrick, and type this URL: http://127.0.0.1:3000/show then I got ActiveResource::ResourceNotFound in ServiceController#show Failed. Response code = 404. Response message = Not Found Any idea? I do not have a deep understanding about using the RoR, activeresource and REST, so any help will do. Many thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/INtNNCz5wpIJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en-US.
Hassan Schroeder
2012-Jul-16 18:22 UTC
Re: Failed. Response code = 404 error. ActiveResource, RoR, REST
On Thu, Jul 12, 2012 at 7:34 AM, Jo <jianping.zhou.1986-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I try to create a RoR app to consume a RESTFul WCF service.> So type http://localhost:50173/RestServiceImpl.svc/json/1999999999999999 in > the browser, it will return a json file on screen.> then I got> Failed. Response code = 404. Response message = Not Found404 is pretty plain; the URL your app is requesting isn''t what your web service is responding to. Look at how they''re different. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en-US.
Matt Jones
2012-Jul-17 12:37 UTC
Re: Failed. Response code = 404 error. ActiveResource, RoR, REST
On Thursday, 12 July 2012 10:34:57 UTC-4, Jo wrote:> > Hi all, > I try to create a RoR app to consume a RESTFul WCF service. > > I used WebInvoke to wrap WCF service then launched it by using Visual > studio > using System; > using System.Collections.Generic; > using System.Linq; > using System.Runtime.Serialization; > using System.ServiceModel; > using System.Text; > using System.ServiceModel.Web; > > namespace WCF_REST > { > [ServiceContract] > public interface IRestServiceImpl > { > [OperationContract] > [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, > BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "{id}")] > string XMLData(string id); > > [OperationContract] > [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, > BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/{id}")] > string JSONData(string id); > } > } > > So type http://localhost:50173/RestServiceImpl.svc/json/1999999999999999 in > the browser, it will return a json file on screen. >You''re getting a 404 because ActiveResource doesn''t know how to formulate a URL for your service - it''s going to be trying: http://localhost:50173/rest_service_impls/1 which obviously won''t work. You''ll either need to figure out how to remap that on the IIS side (surely there''s an equivalent of mod_rewrite) or dig into the ActiveResource docs to tell *it* how to create the correct URLs. --Matt Jones -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/YyhiIOMref0J. For more options, visit https://groups.google.com/groups/opt_out.