Interview Questions

Web Service

HATEOAS (Hypertext as the Engine of Application State)

HATEOAS (Hypertext as the Engine of Application State)

It is a constraint in REST based architecture, to provide HREF links to resources as part of rest api response.
By this way , the user can navigate to subsequent resources provided by the REST service.

{
       "id": "47cc4ae4-648c-4fc4-ae26-4ad8e90bdeca",
       "username": "CraigJ",
       "email": "craig.jonathan@tdd.com",
       "password": "password",
       "firstName": "Craig",
       "lastName": "Jonathan",
       "isPasswordGotReset": true,
        "links": [ {

WebService Interview Questions & Answers

Web Service provides the standard for communication between different software applications that are running in different platform.

The below are the list of Questions and Answers for Web Services.

Apache Axis2

Apache Axis2 is a Web Services , Simple Object Access Protocol (SOAP) and Web Services Description Language (WSDL) Engine.

The below are the list of articles/examples developed for Axis2.

Learn Axis2 Web services programming in a simple and easier way Smile

Axis2 File Receiver

In this article lets discuss about how to receive a file using axis2 web service.

Consider a scenario where you want to receive a file from a server using web service. It can be done using MTOM.

MTOM is the W3C Message Transmission Optimization Mechanism, a method of efficiently sending binary data to and from web services. It uses XOP (XML-binary Optimized Packaging) to transmit binary data.

Axis2 framework supports MTOM to receive files from a web service. Lets see a simple example for the same.

Axis2- Web Service Client

In this article lets discuss about how to access a web service using axis2.

Lets create a Java class which has only one operation "getUniqueCharCount()".

AxisWebService Class

package in.techdive.axis2.samples;

public class AxisWebService
{

    /*
     * This method returns a string containing number of occurrence of each character from the input string. It is case sensitive.
     */

    public String getUniqueCharCount(String s)
    {

        int[] ascArr = new int[123];
        int[] ordArr = new int[s.length()];

Axis2 - Web Service Implementation using WSDL

In this example, Let us see how to create a Web Service implementation using WSDL.

Let us assume, we are going to perform the implementation for Student Record system. Now, lets develop the Web Service which will accept Student Roll Number and retrieves the respective Student Name. If the Roll Number is not found, then Error will be thrown.

Let us see how to achieve this in Axis-2 SOAP Engine.

Consider the following WSDL for Student processing.

Student.wsdl

<?xml version="1.0" encoding="UTF-8"?>

Axis2 - Simple Web Service Example

In this section, let us see how to create a Simple Web Service using Axis-2 Web Services Engine.

Lets create a simple Java class which has only one operation "getName()".

SimpleWebService Class

package in.techdive.axis2.samples;

public class SimpleWebService
{
        public String getName(String p_name) throws Exception
        {
                return p_name;
        }
}

Create a XML file named services.xml file as follows,

services.xml

<service name="SimpleWebService">
   
    <description>
        Simple WebService Demo

SAAJ - Web Service SOAP Client

In this article, lets discuss about accessing a Web Service using SAAJ.

What is SAAJ?
SOAP with Attachments API for Java (SAAJ) is mainly used for dealing directly with SOAP Request/Response messages which happens behind the scenes in any Web Service API. It allows the developers to directly send and receive soap messages instead of using JAX-WS.

Let's see an example of how to access the Web Service created in the Axis2 - Simple Web Service Example.