Sunday 6 September 2015

Java Source World: Introduction to SOAP based Java web services


Overview and Need for SOAP

In SOAP 1.1, SOAP stands for Simple Object Access Protocol but with SOAP 1.2, this acronym has been withdrawn and is simply used to refer to XML messages. Protocol is a set of rules for communication between two entities. This means that SOAP is a protocol which is defining the rules for some information exchange among remotely located entities (which is invocation of operations on the remote side). Now the obvious question that comes to mind is why the need of such protocol when I can use something like COM/DCOM in .Net and RMI in Java for method invocation. The answer is that the purpose of SOAP based web services is to invoke operations/methods across programming languages. Thus by using SOAP, we can make .Net function calls from Java code and vice versa. The only requirement for doing so is that both the .Net and Java code should comply with the SOAP rules.
Why the term Web Services?

Now a typical question which arises is when two programs written in .Net and Java are interacting without using any web pages then why do we use the term SOAP based web services. This is because the SOAP based server and client programs exchange SOAP messages for method/operation invocation. These SOAP messages have to be transmitted by using a communication protocol like HTTP, SMTP, ATOM or JMS but most of the times it is HTTP. Since HTTP is so widely used for SOAP based services that we call them SOAP based web services. Ideally they should be called SOAP services. A service is an offering by the server to its client.

Common Definitions

In next few tutorials, we shall cover various aspects of SOAP based web services but let us understand the very common terminologies first.

SOAP : It is used to refer to the SOAP messages. The XML messages that are exchanges between server and client need to comply with the rules laid by SOAP and these messages themselves are also known as SOAP messages.

WSDL (Wiz-dhull) : It is an XML used to describe the details of web service. When the server exposes a service to its client, it needs to tell a number of details like the name of operation, input parameters, output to expect, structure of SOAP message, file attachment to use and security measures. There are fixed XML elements defined for a WSDL which need to be used for writing a valid WSDL file. Thus WSDL is a set of information to the client so that he can send the request to server in the format expected by server. If we don’t have a WSDL in place, clients will never be able to send proper and expected SOAP request messages to the server. A WSDL is always necessary while publishing the web service.
Service Endpoint : This is a URI which is used to identify the web service. You should view it as the address of web service. There could be multiple operations exposed by a web service on an endpoint.

Service Endpoint Interface : This is an interface which defines the web service operations/methods/functions in an abstract way without providing implementation for these operations. This interface is also used for creating the web service client.
Service Implementation : In any programming language including Java, there has to be a concrete implementation of the web service operations. The service implementation class implements the Service endpoint interface (SEI) to ensure that all service operations are implemented.

JAX-WS : It stands for Java API for XML – Web Services. It is a standard which defines how to implement SOAP web services and client in Java. There are many reference implementations for JAX-WS available in the market like Apache Axis and Apache CXF.

Read about: Differences between SOAP and REST
java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String

No comments:

Post a Comment