views:

463

answers:

2

I'm trying to consume a RESTful WCF service in a Rails app using ActiveResource.

My ActiveResource class is:

class PartReferenceService < ActiveResource::Base
    self.site = "http://localhost:1234/"
end

The WCF URL is

http://localhost:1234/PartReferenceService.svc/

and it returns XML like:

<ArrayOfReferenceDataModel xmlns="http://schemas.datacontract.org/2004/07/RemoteService.Model" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;
 <ReferenceDataModel>
  <Description>0460-0054</Description> 
  <Id>147</Id> 
  </ReferenceDataModel>
 <ReferenceDataModel>
  <Description>0960-0095</Description> 
  <Id>145</Id> 
  </ReferenceDataModel>
</ArrayOfReferenceDataModel>

I'm getting a 404 when I do:

PartReferenceService.find(:all)

I also can't find the URL that is being requested in my development.log file.

Any suggestions on where I may be going wrong? I'm fairly new to ActiveResource, and WCF for that matter, but my guess is that ActiveResource is creating a url like,

http://localhost:1234/part_reference_service/

but as I can't see anything in the logs I'm flying blind.

I'm in control of both ends so am able to make any changes needed.

Any help is much appreciated.

A: 

Use Fiddler to see exactly what is going on in the http requests.

Darrel Miller
I managed to get the development.log file on my rails app out puting the URL requested using: ActiveResource::Base.logger = ActiveRecord::Base.logger If I can remove the extension from the .xml request I think I'll have cracked it.
chrisvmcd
A: 

First thing with ActiveResource - alwasy set the ActiveResource::Base.logger. Typically I just do ActiveResource::Base.logger = ActiveResource::Base.logger in my environment.rb after the config block.

Second thing with ActiveResource - it's a pretty horrible library, especially to use with a HTTP over XML api other than one produced by Rails (like one from WCF like you have). I've rolled my own solution, perhaps you'll like it - it's called Wrest.

Kai Wren