You are on page 1of 19

Tutorial 4 – SOAP

Web Services

SOEN 487 - Web Services and Applications


By: Konstantinos Psimoulis
Web Service Technologies

There are two technologies that are primarily used when developing web services:

● SOAP (1998) Initially called XML-RPC


Wiki

● REST Developed 1996-1999, Published in 2000


Wiki

Winter 2021
REST vs SOAP

“Some experts argue that comparing these two types of APIs is like comparing apples to
oranges. They emphasize that SOAP is a protocol and REST is an architectural style.”

Reference: https://rigor.com/blog/restvs-soapapis/

Winter 2021
What is a SOAP API?

- Like REST, SOAP is an acronym that


stands for Simple Object Access
Protocol.
- It is a standardized communication
protocol system that helps differing
operating systems communicate.
- SOAP is standardized and thus more
reliable and secure than REST, but it
lacks in ease of use and performance.
- SOAP vs REST

Winter 2021
WSDL Document

WSDL is an XML based definition language, used to describe the functionality of a SOAP based
web service. Essentially it helps generate the functions of a web service for a client to interact
with.

We will be generating a WSDL file and then using the java function wsimport to generate the
function calls on the client side.

More info on WSDL here.

Winter 2021
JDK 8 is required

For this tutorial, we will be using a Java framework named JAX-WS, which simplifies SOAP
requests. The issue with JAX-WS is that some of the necessary functions only work on JDK
versions before 8.

We will go through the steps on how to download JDK 8 and how to change the necessary
settings for IntelliJ to use it properly.

Install link for JDK 8: Zip file

Winter 2021
Application Server

Same as with the REST implementation, we will be using the Grizzly HTTP server module in this
tutorial.

You can still any other application server if you wish, just make sure it can work with JAX-WS.

Winter 2021
SOAP UI

SOAP UI is an interface that makes testing our SOAP and REST APIs much easier. We will go
through how to add a SOAP project and how to call functions.

Install link for SOAP UI: Download

Winter 2021
Netbeans

Netbeans is an open source IDE created by the Apache Software Foundation. It is a popular Java
IDE which is fairly easy to use.

Install link for Netbeans IDE: Download

Download the EE version and when


installing, make sure you select JDK8
as the version used by Netbeans.

Winter 2021
Starting the Project

Simply download/clone it from the Github Repository and open it using IntelliJ or Netbeans.

Winter 2021
Starting the Project
Make sure that the java version is properly set for IntelliJ and maven

Winter 2021
Base Classes

Winter 2021
Service Publisher Class

The service publisher class will be responsible for publishing our web service on a local URL. We
will use the grizzly http server methods installed from our pom.xml to accomplish this.

On a side note, you can also publish a web service using javax’s Endpoint class instead.

Example here.

Winter 2021
Service Publisher Class

Winter 2021
StudentData Class

Winter 2021
Client Implementation

To test our web service we run ServicePublisher, either through IntelliJ or through maven.

Maven example:

mvn install
mvn exec:java –Ppublisher

We then use the published wsdl to


test from SoapUI:

Winter 2021
Client Implementation

We can also test the web service without using SoapUI. This can be achieved using the JDK 8
command wsimport, e.g:

wsimport -d src/main/java -p com.example.soap.client.service –keep


"http://localhost:8090/helloworld?wsdl"

This will create the necessary files to use the web service in our Client class.

Winter 2021
Client Implementation

After creating this class you can run it the same way we ran
the Service Publisher
Winter 2021
References

- SOAP Wiki
- REST Wiki
- SOAP vs REST
- WSDL Info
- SOAP API Image
- SoapUI Logo
- Grizzly logo
- Netbeans Logo

Winter 2021

You might also like