JAX-WS Interview Questions (2024) | TechGeekNext


JAX-WS Interview Questions (2024)

  1. What is JAX-WS?
  2. What is the difference between JAX-RS and JAX-WS?
  3. What is SOAP in JAX-WS?
  4. What is WSDL in JAX-WS?
  5. Why XSD is used with WSDL in JAXWS?
  6. What is wsimport in JAX-WS?
  7. How to use wsimport to generate the file JAX-WS?
  8. What is the difference between wsgen and wsimport?
  9. What is Service Endpoint Interface in JAX WS?
  10. Which annotation is used to mark the class as web service implementation in JAX WS?
  11. What is the use of annotation @WebMethod and @WebParam in JAX WS?

Q: What is JAX-WS?
Ans:

The Java API for XML Web Services (JAX-WS) helps to simplify the creation and consumption of SOAP (Simple Object Access Protocol) web services. Remote procedure calls are used to access the Web Services. SOAP protocol is used for data transfer between the client and the Web Service. Messages are exchanged between the client and the server using XML-based SOAP messages. JAX-WS

Q: What is the difference between JAX-RS and JAX-WS?
Ans:

JAX-WS handles SOAP calls, whereas Java API for RESTful Web Services(JAX-RS) handles REST calls. RESTful Web Services are represented as resources using Uniform Resource Identifiers (URI). In this scenario, a remote procedure call is expressed by an HTTP-request.

Q: What is SOAP in JAX-WS?
Ans:

SOAP is a messaging protocol that uses XML to exchange information over the internet. SOAP messages are written entirely in XML, making them platform and language neutral. An Envelope that identifies the start and end of the message is included in a SOAP message. SOAP is XML-based and so works best with many frameworks. JAX-WS is a framework that makes it easier to use SOAP.

Take a look at our Suggested Posts :

Q: What is WSDL in JAX-WS?
Ans:

The Web Services Definition Language (WSDL) defines an XML language for specifying a service with its list of endpoints that interact with messages. WSDL acts like a contract specification between the given services. It defines the input, output messages as well as how to call the web service. It is language-independent and specified in XML.

Q: Why XSD is used with WSDL in JAXWS?
Ans:

XSD evaluates the document and provides XML metadata such as datatypes, elements, and length, whereas WSDL describes the webservice location and operations. To determine whether a web service WSDL is valid, we can compare it to an XSD.

Q: What is wsimport in JAX-WS?
Ans:

The wsimport utility parses an existing Web Services Description Language (WSDL) file and generates the necessary files (JAX-WS portable artifact) for web service clients to access published web services.

Q: How to use wsimport to generate the file JAX-WS?
Ans:

The wsimport tool is included with JDK and can be found in the bin folder of your JDK installation. We will generate java artifact from our wsdl file using the command below.

D:\JAXWSExample\src>wsimport -s . http://localhost:8080/UserService?wsdl parsing WSDL...

Generating code...

Compiling code...

Q: What is the difference between wsgen and wsimport?
Ans:

wsgen and wsimport produce request and response wrapper bean classes, as well as JAXB classes. Moreover, wsgen creates the JAXB classes and places them in a jaxws folder, whereas wsimport does not place such classes in any folder and instead places them in the current directory.

Q: What is Service Endpoint Interface in JAX WS?
Ans:

A service endpoint interface (SEI) is a Java interface that defines the methods that a client can use to interact with the service. When creating a JAX-WS endpoint, no SEI is needed. The web service implementation class defines an SEI implicitly.

Q: Which annotation is used to mark the class as web service implementation in JAX WS?
Ans:

The @WebService annotation indicates that the class is a web service implementation class.

package com.techgeeknext.services;

import javax.jws.WebService;

@WebService
public class EmployeeServiceImpl implements EmployeeWS {
.....
.....
}

Q: What is the use of annotation @WebMethod and @WebParam in JAX WS?
Ans:

  1. For the methods that implement web service operations, we use the @WebMethod annotation.
  2. The @WebParam annotation is used to receive web service parameters from the client.
  3. package com.techgeeknext.services;
    
    import javax.jws.WebService;
    
    @WebService
    public class EmployeeServiceImpl implements EmployeeWS {
    
    @Override
    @WebMethod
    public String postEmployee(@WebParam(name="Emp") Employee addEmp) {
    
    return ....;
    
    }
    ....
    }
    








Recommendation for Top Popular Post :