Failed. Response code = 404 error. ActiveResource, RoR, REST

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:

Hello Ruby!

<%= @wcf_service %>

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.

On Thu, Jul 12, 2012 at 7:34 AM, Jo [email protected]
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 Found

404 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 S. ------------------------ [email protected]

twitter: @hassan

On Thursday, 12 July 2012 10:34:57 UTC-4, Jo wrote:

using System.ServiceModel;
BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = “{id}”)]
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 J.