简体   繁体   English

需要资源从SCRATCH学习Java Web服务

[英]Need Resources to Learn Java Web Services from SCRATCH

I've bounced around Java and C# the last several years but now want to get up to speed with Web Services (RESTful). 我在过去的几年里围绕Java和C#蹦蹦跳跳,但现在想要加快Web服务(RESTful)的速度。 I used to be a master of J2EE circa 2003, but have since got side tracked into all kinds of stuff. 我曾经是大约2003年的J2EE大师,但后来被追踪到各种各样的东西。 I've worked through a couple of NetBeans tutorials (my IDE of choice) but they don't seem to expose the nitty gritty. 我已经完成了几个NetBeans教程(我选择的IDE),但它们似乎并没有暴露出细微之处。 I enjoy seeing how things exactly work, building an app from the byte array up. 我喜欢看到事情的确切工作,从字节数组构建应用程序。

Although I've touched a couple of frameworks, I've most enjoyed working with Java EE proper to understand the base case before the sugar of Spring/Hibernate is added. 虽然我已经触及了几个框架,但我最喜欢使用Java EE,以便在添加Spring / Hibernate的糖之前理解基本情况。

Does that make sense? 那有意义吗? I am looking for a book or tutorial that really builds up your knowledge piece by piece so that you understand everything, not some Rails-like toolkit for rapid development. 我正在寻找一本书或教程,它真正地逐步建立你的知识,以便你理解一切,而不是一些类似Rails的快速开发工具包。

Thanks-in-advance, 提前致谢,

Guido 圭多

I'd start by doing a review of HTTP, since in practice this is a fundamental building block of REST web services, and it gets you into the right mindset for what comes next. 我首先回顾一下HTTP,因为在实践中,这是REST Web服务的基本构建块,它可以帮助您进入下一步的正确思维模式。

Next, think about how you'd structure the URIs for various resources. 接下来,考虑如何为各种资源构建URI。 Martin Fowler wrote a good article on this topic. Martin Fowler写了一篇关于这个主题的好文章 Various java frameworks for creating web services try to make it easier for you to map requests to specific methods, and even to map parts of requests (including path elements, query parameters, and the entire request body) straight into your object model. 用于创建Web服务的各种Java框架尝试使您更容易将请求映射到特定方法,甚至将请求的一部分(包括路径元素,查询参数和整个请求主体)直接映射到对象模型中。 But all of this just help with the identification and manipulation of resources through URIs. 但所有这些只是通过URI识别和操纵资源。

Next, if your resources are related, then think about hypermedia controls . 接下来,如果您的资源是相关的,那么请考虑超媒体控件 You're probably used to putting <a href=""> links in web pages, and you certainly wouldn't want people to hardcode or bookmark every single URL in your website. 您可能习惯将<a href="">链接放在网页中,您当然不希望人们对您网站中的每个网址进行硬编码或书签。 How does the same idea extend to web services? 如何将相同的想法扩展到Web服务?

Next, think about actually moving data between client and server. 接下来,考虑实际在客户端和服务器之间移动数据。 JSON or XML? JSON还是XML? URI element or query parameter? URI元素或查询参数? Again, lots of java frameworks exist just to make this easier -- for example, Jackson and Gson for REST, JAXB for XML, etc. -- but the problem of dealing with HTTP-based requests and responses is very similar to the one that your average servlet container solved years ago. 同样,为了使这更容易,存在许多java框架 - 例如,用于REST的Jackson和Gson,用于XML的JAXB等等 - 但是处理基于HTTP的请求和响应的问题非常类似于几年前你的平均servlet容器已经解决了。

Finally, consider security. 最后,考虑安全性。 For example, username/password or OAuth? 例如,用户名/密码还是OAuth? HTTP or HTTPS? HTTP还是HTTPS?

There are lots of other details, but these topics should keep you busy for a while. 还有很多其他细节,但这些主题应该会让你忙碌一段时间。

Have you checked out Jersey yet? 你看过泽西了吗? This is the Java reference implementation of JAX-RS. 这是JAX-RS的Java参考实现。 There is a great community around this project, and the main author is available via mailing lists and forums and has personally answered questions of mine for some gnarly situations I ran into. 这个项目周围有一个很棒的社区,主要作者可以通过邮件列表和论坛获得,并亲自回答了我遇到的一些问题。 The jersey site has a lot of great links to get you started from a variety of angles, depending on what you're interested in learning. 球衣网站有很多很好的链接,可以让你从各个角度开始,这取决于你有兴趣学习什么。

RestifyDayTrader has very good details of how to build a RESTFul service. RestifyDayTrader有关于如何构建RESTFul服务的非常好的细节。 Java implementation can be found at Restified Trader 可以在Restified Trader中找到Java实现

Java Web Services是学习Web服务的好书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM