Good evening, dear listeners. We will start today's webinar with the “JavaEE Developer” course program in the Otus educational project. As part of the current webinar, we will go over the main blocks of the program, focusing only on the main technologies that will be considered in class, and try to avoid the development of holivar on the comparison of the JavaEE and Spring stack. In this course, I tried to take into account the most relevant topics of this stack, which are actively used in the corporate sector and will be useful for a specialist in this field. The peculiarity of the course lies in its practical orientation, obtaining real skills in developing applications at the Enterprise level, as well as analyzing the processes occurring “under the hood” of each of the technologies. The program of this course is available on the website , where you can find detailed information about the purpose of the course, its basic blocks up to breakdown by occupation and practical work, as well as a little about the author of the course. It is quite logical to start the course with the infrastructural moments of this stack, dive into the world of servlet containers and server running, having become thoroughly acquainted with the reference representatives of Tomcat and GlassFish, respectively. Also in this block will be discussed issues related to the level of data in the three-tier model of the application, and issues of interaction through common data formats: XML and JSON. In the second block, we will introduce web technologies that are included in the JavaEE stack, namely, the Servlet API, JSP, modern web frameworks, related HTML, JS, CSS technologies. The third block is devoted to a service-oriented architecture, where special attention will be paid to the specifications of JAX-WS and JAX-RS. For the business logic block, the main focus will be on EJB technology, as well as on queuing and processing with JMS tools. In the fifth block, we will learn about the important aspects of modern Enterprise applications: security, logging, testing, etc. The final stage of study in this course is the execution of project work, which should be considered as a stage in creating your own portfolio for your future career. According to the program of the course, I think it’s quite enough, we will get to know it in more detail at the bottom of the open door and analyze all your questions.
The reason for today's meeting was the topic “Building an API using SOAP and REST services”, which turned out to be the winner in the preliminary voting. Indeed, this topic causes a heated discussion in the circles of developers and you can find a lot of useful information on the Internet. Before embarking on the practical part of the webinar, I would like to dive a bit into the theory on this issue and determine the purpose of the webinar. The goal of the lesson is to gain development skills for JavaEE applications that provide APIs for external use through SOAP and REST services.
')
First, let's figure out what the API is, and how do you understand its main purpose? The API is decoded as the Application Programming Interface and provides access to some system functionality with the ability to get results when passing certain input parameters. An application development interface arises when the developed functionality may be useful for external use and for reusability. As well-known APIs, existing solutions in the field of social networks (Vkontakte, Facebook, Instagram), brokerage systems, banking, etc. can be mentioned. At the same time there is an important feature of the development of such a system: when we develop familiar user applications, the opinion about the system is formed according to external characteristics such as the designed interface of the application and errors that occur during its operation. When developing an API, you should also take into account an equally important aspect (akin to usability) - the main user of your application will be another developer or team who wants to use your work while developing their product. And here it is important to look at the API from a potential user, for whom it is important to complete the task, having achieved the goal, minimizing the amount of effort when working with the API. Consumers of this functionality can be completely different platforms: websites, portals, mobile devices, information systems, cars, game consoles, etc. At the same time, it is always important to keep such basic points in mind when developing an API, such as a clear interaction protocol, a used data format for communications, documentation of the services provided, security issues and much more. Generally speaking, the concept of API can be found in a large number of areas, among which there is also an SOA. As you have probably already guessed, the basic architecture of SOA looks like this: there is a service provider (we will call it a server) providing secure access to its “services” for end users (clients). In order for the client not to spend a lot of time searching for the necessary functionality, it is important to have a service catalog with a description of all the subtleties of the interaction protocol (a list of input parameters and an output with the data types used).
Among the well-known approaches in the development of services (they are web services), SOAP and REST services have become widespread. Speaking of the first, you should refer to the official documentation (https://docs.oracle.com/javase/7/docs/technotes/guides/xml/jax-ws/) according to the JAX-WS specification defined in the JavaEE stack. In this case, the SOAP service should be viewed as some business logic provided as a service to the client through the service provider. The main implementations of this specification should be noted such libraries as Metro, Apache CXF, Axis 2, Spring WS. In our case, we will get acquainted with the capabilities of the Axis2 framework (although, in principle, the libraries provide similar functionality with some differences: as an independent task, a comparative analysis of the capabilities provided by the frameworks can be performed). How is the development of a web service in Java, we will look at the practical part.
Unlike SOAP, REST should not be taken as a strict protocol that defines all aspects of client-server interaction, but as an architectural style of service development. The more principles defined by REST author Roy Fielding, you follow when developing services, the more RESTful it can be considered. Among the known implementations should pay attention to RESTEasy, Jersey and Restlet.
At this point we will finish with the theoretical part and the time to begin practice.
Comments are unnecessary here, to see the result of this lesson you should refer to the project available on GitHub .
According to the results of the webinar, you can consider the goal set!
Thanks for attention! See you again!
Source: https://habr.com/ru/post/342956/
All Articles