初学者设计模式问题(涉及Web服务)
我是网络服务世界的菜鸟。我需要开发一个登录验证器模块并将其公开为服务。我希望它独立于服务,即将来我应该可以选择将其公开为 SOAP 服务或 REST 服务。
我应该遵循什么模式?抱歉,如果我不清楚我的要求,我可以根据需要进行澄清。
谢谢 !!
编辑:我使用 Eclipse 作为 IDE 和 Jersey 库。我不喜欢任何框架,只是使用 MVC 模式。我发现 SOAP 和 REST 方法之间有很多差异,因此我希望我的方法独立于实现 - 即我应该能够根据需要轻松地通过 SOAP 或 REST 服务调用来使用我的方法。我应该怎样做才能获得最大的灵活性?
I am a noob to web services world. I need to develop a login validator module and expose it as a service. I want it to be service independent, i.e I should have the option of exposing it as a SOAP service or REST service in the future.
What pattern should I follow ? Sorry if I am unclear in my requirements, I can clarify as per need.
Thanks !!
Edit : I am using Eclipse as an IDE and Jersey libraries. I am not into any framework, simply using the MVC pattern. I find a lot of difference between SOAP ann REST methods, so I want my methods to be implementation independent - i.e I should be easily able to use my method through a SOAP or REST service call as per need. What should I do for maximum flexibility ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
选择一个好的 MVC 框架并了解如何正确使用它可以帮助确保您的功能“独立于服务”。我读过的大多数关于优秀框架的文档都建议您将业务逻辑与控制器分开。
如果您阅读所使用工具的文档,并确保业务逻辑和控制器之间有一个层,那么从 SOAP 切换到 REST 或其他协议的工作就会变得非常非常容易。
既然您在下面的评论中提到您正在使用 Eclipse,我假设您正在使用或愿意使用 Java:
Restlets
http://www.restlet.org/
Spring 3.0 REST
http://blog.springsource.com/2009/ 03/08/rest-in-spring-3-mvc/
Picking a good MVC framework and understanding how to use it properly can help ensure that your feature is "service independent". Most of the documentation I've read for good frameworks suggest that you keep your business logic separate from your controller.
If you read the documentation for the tools that you use, and ensure that there is a layer between your business logic and your controllers, then that will make the job of switching from SOAP to REST or some other protocol much, much easier.
Since you mentioned you're using Eclipse in your comment below, I'm assuming you are using or are willing to use Java:
Restlets
http://www.restlet.org/
Spring 3.0 REST
http://blog.springsource.com/2009/03/08/rest-in-spring-3-mvc/
就是这样 !
That's it !