Introduction to SOAP web service – A JAX-WS specification

In this article, we will learn and understand about SOAP web service

Web Service

An inter-operable service hosted & up-running over the web, which could be accessed by different independent clients like web browser or SOAP UI or Java client

Key points about web service

  • Web service are self-describing using WSDL
  • Communicates using open protocols such as SOAP/HTTP
  • Can be discovered using UDDI – a business registry
  • Interaction between disparate systems using common language i.e. XML
  • Loosely coupled as these interactions are platform-independent and language-independent
  • Schema (XSD) can be used to describe request/response message pattern

For detailed explanations about web service see here

SOAP Web Service

In SOAP based web service, there are basically two approaches used to implement/develop the service

  • Top Down approach (or Contact First)
  • Bottom UP approach (or Contract Last or Code First)

In Top-Down approach, WSDL (i.e. Web Service Description Language) are written first with the help of the XSD (i.e. XML Schema Definition) to represent message exchanges i.e.; Request and Response for the web service exposed operations

In Bottom-UP approach, Java code/logics are implemented first and later we can generate artifacts with the help of Maven tool using goals such as wsgen or java2ws in the plugins defined in pom.xml. For simple cases, we can use command line interface

JAX-WS Specification

JSR 224 is a specification request for JAX-WS 2.0/2.1/2.2 specification i.e.; Java API for XML-based Web Service. Its predecessor is JAX-RPC i.e.; Java API for XML-based Remote Procedure Calling

Read full specification about JSR 224 here and various JAX-WS related specifications can be found here

JAX-WS RI (Reference Implementation)

Initial development for JAX-WS code came from Sun Microsystems and later when Oracle acquired Sun Microsystems, now it is under the umbrella of Oracle Corporation

Currently, there are many reference implementations available to implement JAX-WS based SOAP web service. They are

  • JAX-WS (available within JDK5 or higher version)
  • Metro from Glassfish (JAX-WS + WSIT)
  • Apache Axis
  • Apache Axis2 (improved version of Apache Axis)
  • Apache CXF (performance-wise comparable to Metro and better than Axis/Axis2)
  • JBossWS from JBoss
  • Oracle Weblogic JAX-WS (available within its application server)
  • IBM WebSphere JAX-WS (available within its application server)

JAX-WS-Introduction

Source: Team benchresources.net

SOAP Web Service Jargons

Commonly used jargons w.r.t JAX-WS based web services are

  • SOAP (Simple Object Access Protocol)
  • WSDL (Web Service Description Language)
  • XSD (XML Schema Definition)
  • JAXB (Java API for XML Binding)
  • UDDI (Universal Description, Discovery and Integration)
  • XML (eXtensible Markup Language)

In the following article, we will discuss and understand these terms (JAX-WS based SOAP web service jargons) in more detail

JAX-WS Annotations

These are the most commonly used JAX-WS Annotations, when developing SOAP based web service. In the upcoming articles, we will understand & use these annotations and implement demo examples

  • @WebService (javax.jws.WebService)
  • @WebMethod (javax.jws.WebMethod)
  • @WebParam (javax.jws.WebParam)
  • @WebResult (javax.jws.WebResult)
  • @SOAPBinding (javax.jws.soap.SOAPBinding)
  • @XmlRootElement (javax.xml.bind.annotation.XmlRootElement)
  • @XmlElement (javax.xml.bind.annotation.XmlElement)
  • @XmlAccessorType (javax.xml.bind.annotation.XmlAccessorType)
  • @XmlType (javax.xml.bind.annotation.XmlType)

And there are many more annotations available depending on the service implementation need, but these are most commonly used JAX-WS annotations. Now we will move on to explore core and other important JAX-WS packages

Core JAX-WS packages

These are the basic core packages available for SOAP based web service implementation

  • javax.jws (WSDL mapping annotations)
  • javax.xml.ws (core JAX-WS APIs)
  • javax.jws.soap (Web Service mapping on the SOAP protocol)
  • javax.xml.ws.soap (SOAP/HTTP binding)
  • javax.xml.ws.http (XML/HTTP binding)
  • javax.xml.ws.wsaddressing (ws-addressing related)
  • javax.xml.ws.handler (message handlers)

 

Read about SoapUI tutorials from guru99.com

 

References

Happy Coding !!
Happy Learning !!

JAX-WS based SOAP Web Service Jargons