Professional Documents
Culture Documents
Web Services
There are two technologies that are primarily used when developing web services:
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?
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.
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.
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.
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.
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
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:
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