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.