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.
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.
20 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.
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 implement web service and its also quite popular these days. It uses HTTP protocol and its various methods instead of a separate protocol to convey information. for example GET can retrieve 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 protocol. 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
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?
REST is a technology to communicate over HTTP. It allows you to post data to the server and retrieve data from server using HTTP methods like POST and GET, while Microservices is an architecture pattern where a system is built by creating multiple small services which does one job well.
This allows faster development as multiple people can work on different services simultaneously, they are also easy to release and maintain
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)
POST mainly used to create data, GET is to retrieve data, PUT is to update data and DELETE is to remove data on server.
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.
20. What is difference between REST and GraphQL? (answer)
While both REST and GraphQL are technology to post and get the data from server one major difference is that GraphQL optimize what REST does. It provide structure which allows you to query multiple data from different endpoints together which means you need to make less calls to server.
For example to get both User and Order data using REST will require two queries, one to user endpoint and other to Order endpoint but with GraphQL you can get both these data in just one query.
Here is a diagram which illustrate difference between REST and GraphQL more clearly:
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
- 10 Tricky Java interview question - Answered
- Difference between PATH and Classpath in Java
- 10 Spring MVC Interview questions and answers
- 10 Java Collection interview questions and answers
- 10 Java Threading Interview Questions and answers
- 15 Spring Cloud Interview Questions with Answers
- 15 Spring Data JPA Interview Questions with Answers
- 15 Spring Boot Questions with Answers for Interviews
- 30 Spring MVC and Spring Core Questions with Answers
- 15 Hibernate Interview Questions with Answers
Thank for reading this article so far. If you have any questions feel free to ask on comments
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
ReplyDeleteadvance 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.
I'd certainly like to say thanks for all this quite valuable information.
ReplyDeleteExcellent job by java67.
ReplyDeletePlease provide the answers for webservices
No, do your homework!
DeleteGreat questions, but how do you implement Security in REST architecture?
ReplyDeletegood list
ReplyDeletehow do you handle session in REST most asked question
ReplyDelete