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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en-US.

Search Discussions

  • Hassan Schroeder at Jul 16, 2012 at 6:22 pm

    On Thu, Jul 12, 2012 at 7:34 AM, Jo 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 Schroeder ------------------------ hassan.schroeder@gmail.com
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en-US.
  • Matt Jones at Jul 17, 2012 at 12:37 pm

    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJul 16, '12 at 8:39a
activeJul 17, '12 at 12:37p
posts3
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase