Top 10 Soap vs Rest Interview Questions & Answers | 2023

SOAP (Simple Object Access Protocol) and REST (Representational State Transfer) are two popular architectural styles used for designing web services. They have distinct differences and use cases.

SOAP is a protocol that allows programs running on different operating systems to communicate with each other over the internet. It relies on XML (eXtensible Markup Language) for message formatting and uses well-defined rules for exchanging information. SOAP is often used in enterprise environments where reliability and security are crucial. It supports advanced features such as encryption, authentication, and formal contracts through Web Services Description Language (WSDL).

On the other hand, REST is an architectural style that leverages the existing capabilities of the web, such as HTTP, to build lightweight and scalable web services. RESTful APIs (Application Programming Interfaces) use simple HTTP verbs like GET, POST, PUT, and DELETE to perform operations on resources. REST emphasizes simplicity, statelessness, and scalability. It is commonly used in web and mobile applications where simplicity, flexibility, and performance are important.

What does Web Services Means?

Web service, web service – a software system identified by a web address with standardized interfaces. Web services can interact with each other and with third-party applications through messages based on certain protocols (SOAP, XML, REST, etc.). The Web service is a unit of modularity when using a service-oriented application architecture. The characteristics of web services include:

  • Interoperability
  • Expandability
  • Ability to machine description processing

What is the difference between SOA and web service?

Service-oriented architecture (SOA) is a modular approach to software development based on the use of distributed, loose coupling replaceable components equipped with standardized interfaces for interaction on standardized protocols.

Software packages developed following the service-oriented architecture are usually implemented as a set of web services interacting over the SOAP protocol,

but there are other implementations (for example, based on Jini, CORBA, based on REST). Web services implementing this concept use XML, JSON, etc., as well as Internet protocols like HTTP (S), SMTP, etc.

What is SOAP?

SOAP (from English Simple Object Access Protocol – a simple protocol to access objects, up to specification 1.2) – the protocol for exchanging structured messages in a distributed computing environment. Initially, SOAP was intended primarily for the implementation of remote procedure calls (RPCs).

Now the protocol is used to exchange random messages in XML format, and not just for calling procedures. The official specification of the latest version 1.2 of the protocol does not decrypt the name SOAP. SOAP is an extension of the XML-RPC protocol.

SOAP can be used with any application layer protocol: SMTP, FTP, HTTP, HTTPS, etc. However, its interaction with each of these protocols has its own characteristics, which must be defined separately. Most often, SOAP is used over HTTP.

What is REST?

REST (abbreviated to English Representational State Transfer) is the architectural style of the interaction of components of a distributed application on a network.

REST is an agreed set of constraints that are taken into account when designing a distributed hypermedia system. In some cases (online shopping, search engines, other data-based systems) this leads to increased productivity and simplified architecture. In a broad sense, components in REST interact like the interaction of clients and servers on the World Wide Web. REST is an alternative to RPC.

On the Internet, calling a remote procedure can be a standard HTTP request (usually GET or POST, which is called a REST request), and the required data is passed as query parameters. For web services built with REST in mind, that is, without violating the restrictions imposed by it, the term “RESTful” is used.

How would you decide which of the REST or SOAP web services to use?

REST versus SOAP can be paraphrased as “Simplicity vs. Standard”. In the case of REST (simplicity), you will have speed, expandability, and support for many formats. In the case of SOAP, you will have more security capabilities (WS-security) and transactional security (ACID).

What is JAX-WS?

Java API for XML Web Services (JAX-WS) is the Java application programming interface for creating Web services that are part of the Java EE platform. JAX-WS is a replacement for JAX-RPC technology, providing a more document-oriented messaging model and simplifying the development of [1] web services by using annotations first introduced in Java SE 5. JAX-WS is a standard and is described in JSR 224. Some advantages:

  • Using annotations eliminates the need to create Web service descriptors.
  • The endpoints declaration occurs directly in the Java classes.
  • Direct integration with JAXB 2.0.
  • Resource injection.
  • Support for MTOM.

The choice between two development paths: bottom-up (the programmer develops endpoint classes himself) and top-down (WSDL generates Java classes).

Tell us about JAXB.

Java Architecture for XML Binding (JAXB) allows Java developers to align Java classes and XML representations. JAXB provides two main features: serialization of Java objects in XML and vice versa, that is, deserialization from XML back to the Java object.

In other words, JAXB allows you to store and retrieve data in memory in an XML format, without having to perform a specific set of procedures for loading and saving XML. It is similar to xsd.exe and XmlSerializer in the .NET Framework.

JAXB is especially useful when the specification is complex and changing. In this case, permanent changes to the schema of XML definitions to synchronize them with Java definitions can take a long time and are prone to errors.

What is MTOM?

MTOM (Message Transmission Optimization Mechanism) – the use of message coding using the mechanism for optimizing the transmission of messages. E the mechanism of transfer of large attachments in binary format SOAP messaging protocol as the raw bytes that are permitted for smaller messages.

What is XOP?

XOP (XML-binary Optimized Packaging) is a mechanism recommended by the W3C for embedding binary data into a set of XML Information Set (XML Information Set).

What do you know about encoding in SOAP (encoding)?

Coding SOAP is a method for structuring a query that is proposed within the SOAP specification, known as SOAP serialization.

What defines the encoding Style attribute in SOAP?

SOAP encoding Style defines the serialization rules used in the SOAP message. This attribute can appear on any element, and the scope of this attribute will extend to all child elements, even those that do not explicitly have this attribute. For default SOAP messages, the encoding is undefined.

What are the two final types of web services using JAX-WS?

  • RPC (remote procedure call) style web service in JAX-WS;
  • document style web service in JAX-WS.

What are the rules for encoding a header entry?

The header must be identified by using a full name that contains the namespace of the URI and the local name. All immediate child elements of the SOAP header must be specified in the namespace.

The SOAP encodingStyle attribute must be used to define the style of the header encoding.

What do you know about the wsimport tool?

The wsimport tool is used to parse existing Web Services Description Language (WSDL file) and generate the required files (JAX-WS portable artefacts) for the web service client to access the published Web service.

Comments are closed.

Scroll to Top