As an enterprise Java developer, you will be spending more time integrating systems via web services & messaging. Java Web Services interview questions are very popular.
Q1. What are the different styles of Web Services used for application integration? and What are the differences between both approaches?
A1. SOAP WS and RESTful Web Service. Web services are very popular and widely used to integrate similar (i.e. Java applications) and disparate systems (i.e. legacy applications and applications written in .Net etc) as they are language neutral.
SOAP vs. REST comparison
Which one to favor? In general, a REST based web service is preferred due to its simplicity, performance, scalability, and support for multiple data formats. SOAP is favored where service requires comprehensive support for security and transactional reliability.
SOA done right is more about RESTFul + JSON, favoring lighter weight approaches to moving messages around than the heavyweight ESBs using WSDL+XML that gave SOA a bad name.
Q2. Differentiate between SOA (Service Oriented Architecture) versus WOA (Web Oriented Architecture)?
SOA and WOA differ in terms of the layers of abstraction. SOA is a system-level architectural style that tries to expose business capabilities so that they can be consumed by many applications. WOA is an interface-level architectural style that focuses on the means by which these service capabilities are exposed to consumers. You can start out with a WOA and then grow into SOA.
According to Nick Gall, “WOA = SOA + REST + WWW“. In the above diagram from the Service Orchestration tier, which is responsible for loosely coupling services,
For the SOA => you will be making SOAP style web services in the “Service Tier“.
For the WOA => you will be making more lighter REST style web services in the “Service Tier“.
Q3. How would you decide what style of Web Service to use? SOAP WS or REST?
A3. In general, a REST based Web service is preferred due to its simplicity, performance, scalability, and support for multiple data formats. SOAP is favored where service requires comprehensive support for security and transactional reliability.
The answer really depends on the functional and non-functional requirements. Asking the questions listed below will help you choose.
1) Does the service expose data or business logic? (REST is a better choice for exposing data, SOAP WS might be a better choice for logic).
2) Do consumers and the service providers require a formal contract? (SOAP has a formal contract via WSDL)
3) Do we need to support multiple data formats?
4) Do we need to make AJAX calls? (REST can use the XMLHttpRequest)
5) Is the call synchronous or asynchronous?
6) Is the call stateful or stateless? (REST is suited for statless CRUD operations)
7) What level of security is required? (SOAP WS has better support for security)
8) What level of transaction support is required? (SOAP WS has better support for transaction management)
9) Do we have limited band width? (SOAP is more verbose)
10) What’s best for the developers who will build clients for the service? (REST is easier to implement, test, and maintain)
Q4. What tools do you use to test your Web Services?
A4. SoapUI tool for SOAP WS & RESTFul web service testing and on the browser the Firefox “poster” plugin or Google Chrome “Postman” extension for RESTFul services.
Q5. Why not favor traditional style middle-ware such as RPC, CORBA, RMI and DCOM as opposed to Web services?
A5. The traditional middle-wares tightly couple connections to the applications. Tightly coupled applications are hard to maintain and less reusable. Generally do not support heterogeneity. Do not work across Internet and can be more expensive and hard to use.
Web Services support loosely coupled connections. The interface of the Web service provides a layer of abstraction between the client and the server. The loosely coupled applications reduce the cost of maintenance and increases re-usability. Web Services present a new form of middle-ware based on XML and Web. Web services are language and platform independent. You can develop a Web service using any language and deploy it on to any platform, from small device to the largest supercomputer. Web service uses language neutral protocols such as HTTP and communicates between disparate applications by passing XML or JSON messages to each other via a Web API. Do work across internet, less expensive and easier to use.
Q6. What is the difference between SOA and a Web service?
A6. SOA is a software design principle and an architectural pattern for implementing loosely coupled, reusable and coarse grained services. You can implement SOA using any protocols such as HTTP, HTTPS, JMS, SMTP, RMI, IIOP (i.e. EJB uses IIOP), RPC etc. Messages can be in XML or Data Transfer Objects (DTOs).
Web service is an implementation technology and one of the ways to implement SOA. You can build SOA based applications without using Web services – for example by using other traditional technologies like Java RMI, EJB, JMS based messaging, etc. But what Web services offer is the standards based and platform-independent service via HTTP, XML, SOAP, WSDL and UDDI, thus allowing interoperability between heterogeneous technologies such as J2EE and .NET.
Java Web Services interview questions & Answers Links:
Latest posts by Arulkumaran Kumaraswamipillai (see all)
- 02b. ⏯ Getting started with Java projects & creating jar files video tutorial - May 29, 2017
- 02a. ⏯ Getting started with Java packages video tutorial - May 29, 2017
- 01. ⏯ Setting up Java step by step video tutorial - May 27, 2017
- 06. Setting up GitHub with Eclipse for Maven based Java projects - May 21, 2017
- 05. ♥ Getting started with Eclipse IDE & Maven step by step tutorial - May 21, 2017
Top 13 most visited by members
- ♦ Q11-Q23: Top 50+ Core on Java OOP Interview Questions & Answers 1,228 views
- ♦ 11 Spring boot interview questions & answers 1,192 views
- 02: ♦ 10 Java String class interview questions & answers 915 views
- ♦ 6 Java Modifiers every interviewer seems to like 816 views
- 01: ♦ 15 Ice breaker questions asked 90% of the time in Java interviews 764 views
- 11: 10+ ♦ Java multithreading scenarios interview Q&As 700 views
- 18 Java scenarios based interview Q&As 604 views
- Flyweight pattern and improve memory usage & performance 372 views
- ♦ Q24-Q36: Top 50+ Core on Java classes, interfaces and generics interview questions & answers... 372 views
- 8 JPA interview questions and answers 300 views
- ♦ Java abstract classes Vs interfaces Interview Q&As 287 views
- 001B: ♦ Java architect interview Q&As on high level architectures 273 views
- 03: ♦ What should be a typical Java EE architecture? 249 views