douaonong7807 2014-09-22 11:37
浏览 45
已采纳

我需要Web API或普通的Web服务吗? [关闭]

My Android app calls for some data that I have stored in my database. I've worked with some Java Dynamic Web Apps, wherein they'll use cxf and write web APIs, catering to the requests. This seemed like the obvious idea for me to take up. So I wrote my REST API, used Jersey, and everything seemed to be working fine.

But then I checked out the cost of hosting a Java app on server, and then I decided to write the API in PHP. I thought that REST was basically just providing different URLs. But then I came across this tutorial here. In this tutorial, the author just makes call to normal PHP files, and that's it. I am echoing JSON encoded data in my PHP script, that I get back. This does not sound very RESTful to me. Maybe because I don't see /getClientInfo,addClientInfo kind of URLs.

Calling normal PHP scripts is just so normal. What did REST add to it?

  • 写回答

1条回答 默认 最新

  • dongnuo6310 2014-09-22 13:05
    关注

    In short: it does not matter. At all.

    The actual API here is an HTTP interface. The web server this all runs on is the API. You're just dressing it up differently by using different URLs or possibly different protocols on top of HTTP, e.g. SOAP or such. But fundamentally nothing changes, you're making an HTTP request and you're receiving data back in an HTTP response, period.

    REST is simply one way to structure your API's URL names and parameter conventions etc., and a way that makes sense in the context of HTTP. But it's not the only way and by itself REST doesn't do anything that's absolutely necessary or not doable any other way.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀