Q. What are the different application integration styles?
A. There are a number of different integration styles like
1. Shared database
2. batch file transfer
3. Invoking remote procedures (RPC)
4. Exchanging asynchronous messages over a message oriented middle-ware (MOM).
Q. What are the different styles of Web Services used for application integration?
A. SOAP WS and RESTful Web Service
Q. How would you decide what style of Web Service to use? SOAP WS or REST?
A. 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.
Q. What are the differences between both SOAP WS and RESTful WS?
A. There are a number of different integration styles like
1. Shared database
2. batch file transfer
3. Invoking remote procedures (RPC)
4. Exchanging asynchronous messages over a message oriented middle-ware (MOM).
Q. What are the different styles of Web Services used for application integration?
A. SOAP WS and RESTful Web Service
Q. How would you decide what style of Web Service to use? SOAP WS or REST?
A. 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.
- 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).Do the consumers and the service providers require a formal contract? (SOAP has a formal contract via WSDL)
- Do we need to support multiple data formats?
- Do we need to make AJAX calls? (REST can use the XMLHttpRequest)
- Is the call synchronous or asynchronous?
- Is the call stateful or stateless? (REST is suited for statless CRUD operations)
- What level of security is required? (SOAP WS has better support for security)
- What level of transaction support is required? (SOAP WS has better support for transaction management)
- Do we have limited band width? (SOAP is more verbose)
- What’s best for the developers who will build clients for the service? (REST is easier to implement, test, and maintain)
Q. What tools do you use to test your Web Services?
A. SoapUI tool for SOAP WS and the Firefox "poster" plugin for RESTFul services.
Q. What is the difference between SOA and a Web service?
A.
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.
Q. Web services when you can use traditional style middle-ware such as RPC, CORBA, RMI and DCOM?
A.
The traditional middle-wares tightly couple connections to the applications and it can break if you make any modification to your application. Tightly coupled applications are hard to maintain and less reusable. Generally do not support heterogeneity. Do not work across Internet. 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 messages to each other via a Web API. Do work across internet, less expensive and easier to use.
Q. What are the different approaches to developing a SOAP based Web service? A. 2 approaches.
Note: The WSDL describes all operations that the service provides, locations of the endpoints (i.e.e where the services can be invoked), and simple and complex elements that can be passed in requests and responses.
Q. What are the pros and cons of each approach, and which approach would you prefer?
A.
Contract-first Web service
PROS:
CONS:
Contract-last Web service
PROS:
CONS:
So, which approach will you choose?
The best practice is to use "contract-first", and here is the link that explains this much better with examples --> contract-first versus contract-last web services In a nutshell, the contract-last is more fragile than the "contract-first". You will have to decide what is most appropriate based on your requirements, tool sets you use, etc.
Note: More Java Web Services interview questions and answers including WSDL, SOAP, UDDI, JAXR, SAAJ, etc are covered in Java/J2EE Job Interview Companion with diagrams.
A. SoapUI tool for SOAP WS and the Firefox "poster" plugin for RESTFul services.
Q. What is the difference between SOA and a Web service?
A.
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.
Q. Web services when you can use traditional style middle-ware such as RPC, CORBA, RMI and DCOM?
A.
The traditional middle-wares tightly couple connections to the applications and it can break if you make any modification to your application. Tightly coupled applications are hard to maintain and less reusable. Generally do not support heterogeneity. Do not work across Internet. 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 messages to each other via a Web API. Do work across internet, less expensive and easier to use.
Q. What are the different approaches to developing a SOAP based Web service? A. 2 approaches.
- The contract-first approach, where you define the contract first with XSD and WSDL and the generate the Java classes from the contract.
- The contract-last approach where you define the Java classes first and then generate the contract, which is the WSDL file from the Java classes.
Note: The WSDL describes all operations that the service provides, locations of the endpoints (i.e.e where the services can be invoked), and simple and complex elements that can be passed in requests and responses.
Q. What are the pros and cons of each approach, and which approach would you prefer?
A.
Contract-first Web service
PROS:
- Clients are decoupled from the server, hence the implementation logic can be revised on the server without affecting the clients.
- Developers can work simultaneously on client and server side based on the contract both agreed on.
- You have full control over how the request and response messages are constructed -- for example, should "status" go as an element or as an attribute? The contract clearly defines it. You can change OXM (i.e. Object to XML Mapping) libraries without having to worry if the "status" would be generated as "attribute" instead of an element. Potentially, even Web service frameworks and tool kits can be changed as well from say Apache Axis to Apache CXF, etc
CONS:
- More upfront work is involved in setting up the XSDs and WSDLs. There are tools like XML Spy, Oxygen XML, etc to make things easier. The object models need to be written as well.
- Developers need to learn XSDs and WSDLs in addition to just knowing Java.
Contract-last Web service
PROS:
- Developers don't have to learn anything related to XSDs, WSDLs, and SOAP. The services are created quickly by exposing the existing service logic with frameworks/tool sets. For example, via IDE based wizards, etc.
- The learning curve and development time can be smaller compared to the Contract-first Web service.
CONS:
- The development time can be shorter to initially develop it, but what about the on going maintenance and extension time if the contract changes or new elements need to be added? In this approach, since the clients and servers are more tightly coupled, the future changes may break the client contract and affect all clients or require the services to be properly versioned and managed.
- In this approach, The XML payloads cannot be controlled. This means changing your OXM libraries could cause something that used to be an element to become an attribute with the change of the OXM.
So, which approach will you choose?
The best practice is to use "contract-first", and here is the link that explains this much better with examples --> contract-first versus contract-last web services In a nutshell, the contract-last is more fragile than the "contract-first". You will have to decide what is most appropriate based on your requirements, tool sets you use, etc.
Note: More Java Web Services interview questions and answers including WSDL, SOAP, UDDI, JAXR, SAAJ, etc are covered in Java/J2EE Job Interview Companion with diagrams.
Key Area
|
SOAP based Web service
|
RESTful Web service
|
Specification/Platform Fundamentals (SF/PF)
|
Transport is platform & protocol neutral. Supports
multiple protocols like HTTP(S), Messaging, TCP, UDP, SMTP, etc.
Permits only XML data format, hence language neutral.
You define operations, which tunnels through thePOST or GET.
The focus is on accessing the named operations and exposing the application
logic as a service.
Defines the contract via WSDL.
|
Transport is protocol specific. Supports only HTTP or HTTPS
protocols.
Permits multiple data formats like XML, JSON data, text, HTML,
atom, RSS, etc.
Any browser can be used because the REST approach uses the
standard GET, PUT, POST, and DELETEweb
operations. The focus is on accessing the named resources and exposing the data
as a service.
Traditionally, the big drawback of REST was the lack of
contract for the web service. This has changed with WSDL 2.0 defining non
SOAP bindings and the emergence of WADL.
Simpler to implement. REST has Ajax support. It can use
the XMLHttpRequest object.
Good for stateless CRUD (Create, Read, Update, and
Delete) operations.
|
Performance Consideration (PC)
|
SOAP based reads cannot be cached. The application that uses
SOAP needs to provide cacheing.
|
REST based reads can be cached. Performs and scales better.
|
Security (SE)
|
Supports both SSL security and WS-security,
which adds some enterprise security features. Supports identity through
intermediaries, not just point to point SSL.
WS-Security maintains its encryption right up to the point
where the request is being processed.
WS-Security allows you to secure parts (e.g. only credit card
details) of the message that needs to be secured. Given that
encryption/decryption is not a cheap operation, this can be a performance
boost for larger messages.
It is also possible with WS-Security to secure different parts
of the message using different keys or encryption algorithms. This allows
separate parts of the message to be read by different people without exposing
other, unneeded information.
SSL security can only be used with HTTP. WS-Security can be
used with other protocols like UDP, SMTP, etc.
|
Supports only point-to-point SSL security.
The basic mechanism behind SSL is that the client encrypts all
of the requests based on a key retrieved from a third party. When the request
is received at the destination, it is decrypted and presented to the service.
This means the request is only encrypted while it is traveling between the
client and the server. Once it hits the server (or a proxy which has a valid
certificate), it is decrypted from that moment on.
The SSL encrypts the whole message, whether all of it is
sensitive or not.
|
Transaction Management (TM)
|
Has comprehensive support for both ACID based
transaction management for short-lived transactions and compensation based
transaction managementfor long-running transactions. It also supports
two-phase commit across distributed resources.
|
REST supports transactions, but it is neither ACID compliant
nor can provide two phase commit across distributed transactional resources
as it is limited by its HTTP protocol.
|
Quality of Service (QoS)
|
SOAP has success or retry logic built in and provides
end-to-end reliability even through SOAP intermediaries.
|
REST does not have a standard messaging system, and expects
clients invoking the service to deal with communication failures by retrying.
|
Best Practice (BP)
|
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,
transactional reliability and stricter contract.
|
Interesting Article
ReplyDeleteJava Web Services Training Online Java Web Services Training Online Java Web Services Online Training Java Web Services Online Training
RESTful Web Services Training RESTful Web Services Training