how to create a web service

此生再无相见时 提交于 2019-12-18 11:43:18

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4993900/how-to-create-a-web-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!