Disclosure: This article may contain affiliate links. When you purchase, we may earn a commission.

Top 15 Java Web Service Interview Questions with Answers

Java Web Services Questions and Answers
Web Services interview questions are part of J2EE interviews for jobs which are looking for some experience in Java web services Space. Most of the Web services questions come from two different ways of implementing Web Services like SOAP and REST. SOAP is standard and mature way of calling Web Services which uses XML while REST is a new way of implementing Web Services which is based on HTTP protocol. In fact REST Web Service interview questions are getting more and more popular on the web services interviews in Java, So if you are going for any Java J2EE interview which require some web service experience, be prepared with both SOAP and REST Web services questions.


Following is a list of Java web services interview questions that I have prepared for practice. Answers to these web services questions can be easily found in many places on the Internet and I will update this list whenever I have new web services interview questions. 

If you guys find any interesting tricky or tough Java web service questions asked in Interviews then please share with us.

Frequently asked Java web services interview questions

Here is my list of frequently asked interview questions on the Java web service in any Core Java Interview. As SOAP is a standard way of making web service call that uses XML, good knowledge of XML and Java is expected from you and Interviewer may ask some XML interview questions as well.

Top 15 Java Web Service Interview Questions




1. What is Web Service?
It's like an API where you send request and receive response but unlike traditional website where you receive HTML response, web service generally respond with JSON or XML. 

2. What is SOAP?
It's a technology to implement web services. SOAP stands for Simple Object Access Protocol which is a messaging protocol that allows distributed elements of an application to communicate. SOAP can be carried over a variety of lower-level protocols, including the web-related Hypertext Transfer Protocol (HTTP).

3. What is REST Web Service?
REST is a short form of REpresentational State Transfer. It's another way to impelement web service and its also quite popular these days. It uses HTTP protocol and its variaous methods instead of a separate protocol to convey information. for example GET can retreive data and POST can create data on a REST web service. 

4. What is the difference between REST Web Service and SOAP web service? (answer)
There are lot of difference between them but REST being lightweight and easier is the most important one. 

REST is also an architectural style protocol unlike SOAP Which is a XML based procotol. Also SOAP is invoked using RPC method while REST web services can be simply called using URL path. You can see the attached link for more differences or refer to below table to compare REST and SOAP

Top 15 Java Web Service Interview Questions with Answers



5. Can a Java client talk to C++ Server using Web Service?
Yes, the main advantage of web services are that client and server can be implemented on different technologies or programming language. They can also be independently development. Since they communicate over XML or JSON which is intendent of any tech to transfer messages or data, you can create a Java client to talk to C++ server. 


6. What is WSDL?
WSDL stands for Web Service Description language and it is used to describe the services offered by any web service. In case of SOAP based web service, you can find all the functions you can call in their WSDL document. 

7. What is UDDI?
UDDI stands for Universal Description, Discovery, and Integration. It's a open specification that defines a way to publish and discover information about Web services. UDDI has two functions: In case of a SOAP-based protocol it defines how clients communicate with UDDI registries and it also contains a  particular set of global replicated registries where anyone can register their web service.

8. Does Web Service call is synchronous or asynchronous?
It could be both but generally asynchronous web service calls are preferred because client doesn't need to wait for the response. It can asynchronously process the response when it receives and continue doing its work. 

9. How do you handle errors in Web Service call?
Can you answer this question?


10. What is JAX-RPC?
JAX-RPC is a Java specification that defines the Java APIs for making XML-based remote procedure calls (RPC). It's an essential library for calling SOAP web services from Java application. 

11. Have you worked on Spring and Web services?
You can answer this question based upon your experience, just be prepared if you answer yes then questions related with how to call a web service using spring may be asked. 

12. What is WebServiceTemplate etc?
Similar to RestTemplate and WebClient, the WebServiceTemplate is the core class for client-side Web service access in Spring-WS. It contains methods for sending Source objects, and receiving response messages as either Source or Result .

13. What is the difference between RMI and Web Services?

14. What is gRPC? What benefits it offers over other Web service Alternatives?

15. What is Microservice Architecture? (answer)

16.  What is the difference between REST and Microservice?

17. What is the difference between the POST and PUT on REST Web Service? (answer)
In REST web service, POST is used to create a new entity while PUT is used to update the existing entity on server. For example, you can create a new book on a BookService using POST but if you want to update any attribute of book like Title then you can use PUT method. But this difference is by convention only, if your server implements on different way then POST and PUT method will behave accordingly. 

18. What is the purpose of different HTTP methods in REST? (answer)

19. How do you test REST web services? (answer)
You can test REST Web Service using tools like Postman or just by using Curl command in Linux. You can also call them by putting URL into browser and you can see the JSON or XML returned on the browser itself. 


That's all about some common Java Web Service Interview Questions you can practice before interviews. This list is not complete and I have started collecting more and more web services questions as part of my preparation. I will be updating this list whenever I have good web services questions from Java interviews.


Other Java Interview Questions from Java67 Blog

7 comments:

  1. Thanks for all the information ,it was very helpful i really like that you are providing information on core and advance java ,being enrolled in
    advance and core java
    http://www.wiziq.com/course/1779-core-and-advance-java-concepts i was looking for such information on advance and core java and your information helped me a lot. I really like that you are providing such information.

    ReplyDelete
  2. I'd certainly like to say thanks for all this quite valuable information.

    ReplyDelete
  3. Excellent job by java67.
    Please provide the answers for webservices

    ReplyDelete
  4. Great questions, but how do you implement Security in REST architecture?

    ReplyDelete
  5. how do you handle session in REST most asked question

    ReplyDelete

Feel free to comment, ask questions if you have any doubt.