5

I building a website with Ruby on Rails framework. The site will contain a flash application that will interact with the rails application using web service. My partner builds the flash application and he told me that the flash application interacts through WSDL file.

I am new to web services. I would like to know how to create the WSDL file, and how to make the interaction between the rails application and the WSDL file.

If you believe that there are better alternatives than SOAP/WDSL, I would like to hear them too.

Thanks,

Oded

Oded Harth
  • 4,367
  • 9
  • 35
  • 62
  • 3
    I would rather use a RemoteObject communication or a REST GET/POST approach instead of web services. Most of time, it's easier to build and performs better, especially with the former. – Florian F Feb 14 '11 at 15:45
  • @Florian This comment would look better as an answer, wouldn't it ? – Dunaril Feb 14 '11 at 16:03
  • 2
    It doesn't really answer the question (how to create a web service with RoR) so I thought it would be better to write a comment :) – Florian F Feb 14 '11 at 16:09
  • 3
    @Dunaril I'm w/ @Florian F on this one. His comment does nothing to answer the question or help solve the original posters problem. If you asked me how to cook hamburgers, I bet you'd be slightly upset if I tried to convince you that hot dogs were better. – JeffryHouser Feb 14 '11 at 16:16
  • @www You convinced me. I cannot resist a gastronomy-based argument. – Dunaril Feb 14 '11 at 16:23

2 Answers2

12

Have you Googled how to build web services in Ruby? Here are a few links that come up, all addressing exactly what you want to do:

http://www.tutorialspoint.com/ruby/ruby_web_services.htm

http://www.ibm.com/developerworks/opensource/library/os-ws-rubyrails/index.html

http://searchsoa.techtarget.com/tip/Web-services-with-Ruby-on-Rails

How about you take a look at some of those links, and come back to us if you have further questions.

I do have one elaboration:

My partner builds the flash application and he told me that the flash application interacts through WSDL file.

It sounds like your partner has an incomplete understanding of how Flash can access remote data services. Using a SOAP Web Service with a WSDL is one method, for sure, and here is some documentation on that.

A Flex / Flash application can also make standard HTTP calls, sometimes called REST Web Services. In many cases, REST Web Services will return an XML Document, but that is not required. Any data, including simple text data, can be returned from a REST Web Service.

What many people prefer to do is to use an AMF Gateway with RemoteObject. AMF is a binary format so you'll get much smaller file size transferred back and forth than the alternatives. It also provides for automatic object translation between your server side objects and client side objects. This can be a time saver in development because you don't have to parse data to turn it into something Flex can use easily. RubyAMF is one Ruby implementation of AMF.

JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
5

You'll be going through more pain than you need to by using WSDL.

Instead, I recommend creating a REST interface that returns json (or xml) -- you'll find in rails it will just work.

So you'll have things like:

/books # returns a list of books. Also do Searching here
/books/1 # return the detail of a book with ID of 1

Search for "REST Rails" and you'll get examples of controllers that will return JSON and XML depending on what the client requests.

Jesse Wolgamott
  • 40,197
  • 4
  • 83
  • 109
  • While I don't necessarily disagree with your thoughts; this doesn't answer the question. As I said in comments on the main question "If you asked me how to cook hamburgers, I bet you'd be slightly upset if I tried to convince you that hot dogs were better." – JeffryHouser Feb 14 '11 at 16:32
  • 2
    The question is "how to create a web service" not "WSDL webservice". I stand by the point that going WSDL without looking at alternatives will be painful. – Jesse Wolgamott Feb 14 '11 at 19:16
  • I understand from your comments that I better check other alternatives before starting with the SOAP/WSDL. I am new to this subject, therefore It will be a great help If you could suggest other alternatives as well. – Oded Harth Feb 14 '11 at 19:24
  • @Oded Harth .. great! I highly, highly recommend using a Rest interface. a Primer: http://thoughtsincomputation.com/posts/understanding-rest-in-rails-3 Here's how to test a REST API: http://www.anthonyeden.com/2010/11/testing-rest-apis-with-cucumber-and-rack-test/ – Jesse Wolgamott Feb 14 '11 at 19:51
  • @Jesse Wolgamott I am pretty familiar with REST. Do you know how can I make I interact with flash? – Oded Harth Feb 14 '11 at 19:58
  • Check out this SO question that lists how to get flex to work with REST: http://stackoverflow.com/questions/153420/is-it-feasible-to-create-a-rest-client-with-flex – Jesse Wolgamott Feb 14 '11 at 20:21
  • @Jesse Wolgamott The subject line was "how to create a web service" the question text explicitly specifies WSDL. – JeffryHouser Feb 15 '11 at 16:50