Web Service Concepts

Contents

keyboard_tab
Web Services
1
2

The course is part of this learning path

Web Service Concepts
Difficulty
Intermediate
Duration
11m
Students
5
Description

In this course, we get to the bottom of what Java Web Services are and then move on to look at the various concepts related to them.

Learning Objectives

  • Learn the basics of Java Web Services
  • Understand the main concepts of Java Web Services

Intended Audience

This course is intended for anyone who already has basic knowledge of Java and now wants to learn about Java EE 6.

Prerequisites

Basic knowledge of Java programming.

Transcript

Hello dear friends. In this video, we will examine web service concepts. So, let's begin. In the previous video, we learned what a web service is and why we require it. There are now two web service approaches that are widely used in the programming world. These are SOAP, REST. Now, let's examine them one by one. First, let's start with SOAP. Simple Object Access Protocol, also known as SOAP, is a messaging protocol specification for exchanging structured information in the implementation of web services in computer networks. It uses XML information set for its message format and relies on application layer protocols. This definition belongs to Wikipedia. Basically. SOAP is an XML-based protocol for accessing web services over HTTP. It has some specification which could be used across all applications. SOAP is a protocol that emerged in 1998.

Today, it's mostly used to expose web services and transmit data over HTTP, HTTPs. The working structure of the SOAP can be seen in this image. With HTTP, the sender requests data and the receiver responds. Because SOAP is an XML-based web service, we can only send and receive XML files with it. So, we must understand the XML message structure. As you can see from the image, an XML message is made up of four parts. Envelope is the core and essential element of every message which begins and concludes messages with its tags enveloping it, hence the name. 

Header is an optional element that determines the specifics extra requirements for the message. Body includes the request or response. So, we can tell the most important part is body. The key point here is that it includes request or response, which means that when we request a message, the system sends our response in the body part. The last one is fault. Fault is an optional part that shows all data about any errors that could emerge throughout the API request and response. Now I think that's enough about SOAP because in this course we will focus on REST. The Java XML Web Services JAX-WS is a Java EE API for creating web services, particularly SOAP services. JAX-WS is one of the java XML programming APIs. In the following lecture, we will examine JAX-WS technology with all details. 

For now, you should know that JAX-WS is a java technology that is used for creating SOAP web services in Java. So, let's go on with REST. What is REST? Representational State Transfer also known as REST, is an architectural style for distributed hypermedia systems describing the software engineering principles guiding REST, and the interaction constraints chosen to retain those principles while contrasting them to the constraints of other architectural styles. REST is a hybrid style derived from several of the network based architectural styles. REST term was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. This image shows us the REST API working structure. 

When a request data is sent to a REST API, it's usually done through HTTP. Once a request is received, APIs designed for REST can return messages in a variety of formats. HTMl, XML, plaintext, and JSON. The most important feature of the REST API is that it does not only work with XML. Services that use REST architecture are called RESTful services. Just like other services, REST services have some principles. An application is said to be RESTful if it follows six architectural guidelines. A RESTful application must have: a client-server architecture composed of clients, servers, and resources.

Stateless client-server communication, meaning no client content is stored on the server between requests. Cacheable data to eliminate the need for some client-server interactions. The layered system style allows an architecture to be comprised of hierarchical layers by constraining component behavior. For example, in a layered system, each component cannot see beyond the immediate layer they're interacting with. And maybe code on demand. I said maybe because this principle is optional and means REST also allows client functionality to extend by downloading and executing code in the form of applets or scripts. The Java EE 6 release took the first step towards standardizing RESTful web service APIs by introducing a Java API for RESTful web services JAX-RS. JAX-RS ensures the portability of REST API code across all Java EE compliant application servers. Following the JAX-WS, we will examine the JAX-RS in great detail using an application. Now that we've covered the definitions, let's look at the differences between SOAP and REST. There are many differences between SOAP and REST, but I will tell you the most important differences. First, and I think most important one is message type.

REST is an architecture that's more data-driven, while SOAP is a standardized protocol for transferring structured information that's more function-driven. REST permits many different data formats including plain text, HTML, XML, and JSON, which is a great fit for data and yields more browser compatibility. SOAP only uses XML. SOAP APIs are limited to using XML and the format including the SOAP envelope header and body as we saw in the example above. REST APIs are however, format agnostic. While the most common format is JSON, formats such as XML, plaintext, and XML are also valid for REST APIs. Let's compare performance. 

SOAP requires more bandwidth for its usage. Since SOAP messages contain a lot of information inside of it, the amount of data transfer using SOAP is generally a lot. But REST does not need much bandwidth when requests are sent to the server. REST messages mostly just consist of JSON messages, so REST is faster than SOAP. If you examine the transfer protocols, SOAP supports SMTP, HTTP, UDP, etc protocols but REST supports only HTTP protocol. REST calls can be cached while SOAP-based calls cannot be cached. I think that's enough about SOAP and REST. In the following video, we will start to examine JAX-WS. See you in the next video.

 

About the Author
Students
1246
Courses
64
Learning Paths
4

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.

Covered Topics