使用未来潜在的 iPhone 和 Android 客户端编写 WCF Web 服务
我们目前正在重写我们的旗舰产品,我们已经到了必须考虑远程和移动访问我们产品的选项的地步。一般来说,我们的产品是由客户购买并自行托管的。目前的状态是使用 NetTcpBinding 上的 WCF 服务来处理与桌面应用程序的交互,并且工作正常。然而,这显然不适合我们的网络和移动客户端。
由于我在 Windows 桌面应用程序开发方面经验丰富,因此在选择 Web 服务技术和策略时,尤其是在必须考虑与其他平台的兼容性时,我有点力不从心。 考虑到以下要求,您会推荐哪种 WCF Web 服务技术?
- 基于用户名/密码的身份验证
- 会话(有状态)行为(尽管在本地处理所有会话信息并使服务无状态< /em> 一个选项)
- 能够从 ASP.NET MVC Web 应用程序、iPhone/iPad 应用程序和 Android 应用程序调用相同的服务(也许以后还有像 WP7 这样的第三平台)
我我知道我可以实现 REST-ful 服务并推出自己的会话管理和身份验证解决方案,但如果可能的话,我更愿意遵守行业惯例。 是否有一种 WCF 技术(或一组技术)能够以与我列出的三个平台兼容的方式处理这些问题?
We're currently in the midst of rewriting our flagship product, and we've reached the point where we have to consider our options for remote and mobile access to our product. In general, our product is purchased and self-hosted by our customers. The current state of things uses a WCF service over NetTcpBinding
to handle the interaction with our desktop application, and this is working fine. However, this obviously isn't a suitable option for our web and mobile clients.
Being more experienced with Windows desktop application development, I am a little out of my depth when it comes to choosing a web service technology and strategy, especially when having to consider compatibility with other platforms. What WCF web service technology would you recommend given the following requirements?
- Username/password-based authentication
- Session (stateful) behavior (though handling all of the session information locally and making the service stateless is an option)
- Ability to call the same service from an ASP.NET MVC web application, iPhone/iPad application, and Android application (and perhaps tertiary platforms like WP7 later)
I know that I could just implement a REST-ful service and roll my own solutions for session management and authentication, but I'd prefer to stick to industry conventions if at all possible. Is there a WCF technology (or set of technologies) that deal with these issues in a way that is compatible with the three platforms I've listed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Windows Communication Foundation (WCF) 中的 REST
REST in Windows Communication Foundation (WCF)
REST 仅使用 HTTP 协议,因此充当 HTTP 客户端的每个设备都可以使用它。它不是一个协议——您正在定义通过 REST 使用的协议。每个移动平台都能够使用 REST 服务,因此您不应在此处遇到任何阻塞问题,如果您不确定,只需尝试进行一些概念证明即可。
使用 WCF 并检查新的 Web-API (它仍然只是预览版,但它将是 WCF 的未来版本),因为它使用 WCF 简化了 REST 服务开发并添加了新功能。对于身份验证,您可以使用 HTTP 中可用的任何内容 - 使用 HTTPS 的基本身份验证将起作用,或者您可以检查 OAuth。
我对你的要求有一个大问题:
代表性状态传输的 REST 状态。从本质上讲,所有状态都应该在请求内转移,因为您要发布新资源、获取现有资源并将它们放回原处。通过放置或发布资源,您可以进行资源中定义的状态转换。完全有状态通信适用于 RPC。但如果不深入了解你的产品,真的很难再思考这一点。
REST just uses HTTP protocol so every device acting as HTTP client is able to use it. It is not a protocol - you are defining protocol used over REST. Every mobile platform is able to consume REST services so you should not reach any blocking problem here and if you are not sure simply try to make some proof of concept.
Use WCF and check new Web-API (it is still only preview but it will be future version of WCF) because it simplifies REST service development with WCF and adds new features. For authentication you can use anything available in HTTP - basic authentication with HTTPS will work or you can check OAuth.
I have one big problem with your requirements:
REST states for Representational state transfer. By nature all state should be transferred within request because you are posting new resources, getting existing resources and putting them back. By putting or posting resource you are making state transition defined in resource. Fully stateful communication is for RPC. But it is really hard to think about this more without deep knowledge of your product.