ios - 是否有一种标准方法可以为 iOS 客户端提供契约优先的 Web 服务端点?

标签 ios swift web-services

我负责一个为 iOS 应用程序生成服务器后端的项目。

我想正式定义供客户端调用的服务接口(interface),以便 IOS、Android 和服务器团队都可以实践契约优先开发。

在黑暗的过去,我们会使用 WSDL 并从中生成 RPC 样式的客户端和服务器互操作样板。然而这并不是 IOS 项目的标准。我们还研究了 Apache Thrift,但没有适用于 Swift 的代码生成器,并且 Objective-C 生成器似乎生成依赖于已弃用的 IOS API 的代码。

这让我们想到了 REST,它是一种移动对象状态的好方法。对于“嘿服务器,使用这些参数执行 X 操作并返回结果”的对话似乎不太好。我们最终只是为特定操作创建服务器端 Controller ,并且这些 Controller 通过坚持获取正确的参数来“定义”服务的调用约定。契约(Contract)最后。

是否有一种标准方法可以为 iOS 客户端进行契约优先的 Web 服务开发,或者我是否必须将文档视为规范?

最佳答案

tl;博士:没有。

I'm not aware of a 'standard' way of doing things, but many client/server apps today do use some incarnation of a RESTful interface. JSON is the usual format.

There are some well documented 3rd party utilities that can handle this for you client side (like [RESTKit][1] in the case of REST), or you can roll your own implementation based on apple's provided NSURLSession or a networking library like [AFNetworking][2]

If needed, iOS can also handle socket-based communication. (3rd party libs exist for this as well.)

[1]: https://github.com/RestKit/RestKit [2]: http://nshipster.com/afnetworking-2/

关于ios - 是否有一种标准方法可以为 iOS 客户端提供契约优先的 Web 服务端点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32958931/

相关文章:

ios - 按部分水平分页 CollectionView

ios - 如何在Sprite Kit框架中逐步执行 "runAction"?

web-services - Tomcat 在调用 session.invalidate() 后不会使 session 无效

ios - 从 VC 到 TabBar 到 VC (iOS) 的 Segue 数据

ios - 触摸 UITableView 时取消手势识别器

iphone - objective-c : UIColor * exception 'NSInvalidArgumentException?

c++ - gsoap,从旧版本迁移 - xml 响应名称和结构已更改

php - Web应用程序集合的数据库设计

ios - 谓词获取所有对象

iOS Model View Controller 设计模式