SOAP

What is SOAP webservice ?

SOAP means Simple Object Access Protocol and it is a standard communication protocol on top of transport protocols such as HTTP, SMTP, Messaging, TCP, UDP, etc.

SOAP uses its own protocol and focuses on exposing pieces of application logic (not data) as services. SOAP exposes operations and is focused on accessing named operations, which implement some business logic through different interfaces.

SOAP only permits XML data formats.

Can SOAP based reads be cached ?

SOAP based reads cannot be cached. The application that uses SOAP needs to provide caching.

What kind of security SOAP webservice supports ?

SOAP based webservice supports both SSL security and WS-security, which add 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.

Does SOAP webservice support transaction ?

It has comprehensive support for both ACID based transaction management for short-lived transactions and compensation based transaction management for long-running transactions. It also supports two-phase commit across distributed resources.

Does SOAP has built-in retry logic ?

Yes, SOAP has success or retry logic built in and provides end-to-end reliability even through SOAP intermediaries.

What is the difference between SOA (Service Oriented Architecture) versus WOA (Web Oriented Architecture)?

WOA extends SOA to be a light-weight architecture using technologies such as REST and POX (Plain Old XML). POX compliments REST. JSON is a variant for data returned by REST Web Services. It consumes less bandwidth and is easily handled by web developers mastering the JavaScript language.

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 with a WOA and then grow into SOA.

When do we need to use SOAP webservice ?

SOAP webservice is mainly favored where service requires comprehensive support for security and transactional reliability.

— Does the service expose business logic ?
— Do consumers and the service providers require a formal contract ?
SOAP has a formal contract via WSDL
— What level of security is required ?
SOAP has better security support
— What level of transaction support is required ?
SOAP WS has better support for transaction management

What tool is required to test SOAP Webservices ?

SoapUI tool is used for SOAP webservice.

What is the difference between SOA and a Web service ?

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 protocol 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 many 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 standard based and platform-independent service via HTTP, XML, SOAP, WSDL and UDDI, thus allowing interoperability between heterogeneous technologies such as J2EE and .NET.

What is WSDL ?

WSDL (Web Services Description Language) is an XML format for describing web services and how to access them.

What is JAX-WS ?

JAX-WS (Java API for XML Web Services) is a set of APIs for creating web services in XML format.

What is JAXB ?

JAXB (Java Architecture for XML Binding) is a Java standard that defines how Java objects are converted from and to XML. It makes reading and writing of XML via Java relatively easy.

Can we send SOAP message with an attachment ?

Yes, we can send different formats such as pdf document, image or other binary file with SOAP message as an attachment. SOAP message is attached with MIME extensions that come in multipart/related.

What is MTOM ?

MTOM (Message Transmission Optimization Mechanism) is a mechanism for transmitting large binary attachments with SOAP message as raw bytes, allowing for smaller messages.

What is XOP ?

XOP (XML-binary Optimized Packaging) is a mechanism defined for the serialization of XML Information Sets that contain binary data, as well as deserialization back to the XML Information Set.

What is a SOAP envelope element?

SOAP envelop element is the root element of a SOAP message which defines the XML document as a SOAP message.

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  ...
  Message information
  ...
</soap:Envelope>

What does a SOAP namespace define ?

SOAP namespace defines the Envelope as a SOAP Envelope.

xmlns:soap=http://www.w3.org/2001/12/soap-envelope

What is the SOAP encoding ?

SOAP encoding is a method for structuring the request which is suggested within the SOAP specification, known as the SOAP serialization.

What does SOAP encodingStyle attribute defines ?

SOAP encodingStyle defines the serialization rules used in a SOAP message. This attribute may appear on any element, and is scoped to that element’s contents and all child elements not themselves containing such an attribute. There is no default encoding defined for a SOAP message.

SOAP-ENV:encodingStyle="http://www.w3.org/2001/12/soap-encoding"

What are two styles web service’s endpoint by using JAX-WS?

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

What is encoding rules for header entries ?

— a header entry is identified by its fully qualified element name, which consists of the namespace URI and the local name. All immediate child elements of the SOAP Header element must be namespace-qualified.
— the SOAP encodingStyle attribute may be used to indicate the encoding style used for the header entries.
— the SOAP mustUnderstand attribute and SOAP actor attribute may be used to indicate how to process the entry and by whom.

What is the wsimport tool ?

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

What is the wsgen tool ?

The wsgen tool is used to parse an existing web service implementation class and generates required files.

What are the advantages of web services ?

Interoperability: By the help of web services, an application can communicate with other application developed in any language.
Reuability: We can expose the web service so that other applications can use it.
Modularity: By the help of web service, we can create a service for a specific task such as tax calculation etc.

What is UDDI ?

UDDI stands for Universal Description, Discovery and Integration. It is a XML based framework for describing, discovering and integrating web services. It contains a list of available web services.

What is contract-first or top-down approach in SOAP ?

Contract-first is where you create the WSDL, and then you can create the implementation from this, and since the WSDL is your contract, this would be contract-first.

Top-down means you start with a WSDL and then create all the necessary scaffolding in Java all the way down.

What is contract-last or bottom-up approach in SOAP ?

Contract-last is where the WSDL is created from the source code, or implementation, so it will most likely be generated by a tool rather than created by the developer.

Bottom-up means you start with a Java method, and generate the WSDL from it.

Difference between Stubs and Skeletons

http://docs.oracle.com/javase/1.5.0/docs/guide/rmi/spec/rmi-arch2.html

RMI uses a standard mechanism (employed in RPC systems) for communicating with remote objects: stubs and skeletons. A stub for a remote object acts as a client’s local representative or proxy for the remote object. The caller invokes a method on the local stub which is responsible for carrying out the method call on the remote object. In RMI, a stub for a remote object implements the same set of remote interfaces that a remote object implements.

When a stub’s method is invoked, it does the following:
1) initiates a connection with the remote JVM containing the remote object,
2) marshals (writes and transmits) the parameters to the remote JVM,
3) waits for the result of the method invocation,
4) unmarshals (reads) the return value or exception returned, and
5) returns the value to the caller.

The stub hides the serialization of parameters and the network-level communication in order to present a simple invocation mechanism to the caller.

In the remote JVM, each remote object may have a corresponding skeleton (in Java 2 platform-only environments, skeletons are not required).

The skeleton is responsible for dispatching the call to the actual remote object implementation.
When a skeleton receives an incoming method invocation it does the following:
1) unmarshals (reads) the parameters for the remote method,
2) invokes the method on the actual remote object implementation, and
3) marshals (writes and transmits) the result (return value or exception) to the caller.

In the Java 2 SDK, Standard Edition, v1.2 an additional stub protocol was introduced that eliminates the need for skeletons in Java 2 platform-only environments. Instead, generic code is used to carry out the duties performed by skeletons in JDK1.1. Stubs and skeletons are generated by the RMIC compiler.