SOAP

Before we need know
1. Core Java
2. Develop Java Web Applications
3. Deploy Java Web Applications

We will know about following:

1. SOAP(JAX-RPC & JAX-WS)
2. REST(JAX-RS)

ATM Application < ---- > Customer DB

Bank1 interaction with Bank2 customer to use ATM

Webservice Architecture:

– How to share information between two inter-operable applications

Webservice Architecture Contains six components:

webservice

1. Java server application needs to share service class details in the format understandable by client application which may be in any programming language.
2. Server application shares information in XML format as XML is a universal language.
3. XML in webservice is called WSDL called web service description language.
4. WSDL file contains name of service class, name of the methods, parameter type, return data types and endpoint URL.
5. Endpoint URL is the location where service is running.
 

Working Process:
 

1. WSDL is an XML file which contains service class details. Service Provider prepares WSDL file using WSDL generation Tool after developing service class.
2. Service class and Endpoint URL as an input to the WSDL generation Tool generates WSDL file.
3. WSDL file is then handover to client using UDDI registry with some unique name. WSDL file is prepared in order for client to know about service classes. If client already knows about the service classes, then WSDL file may not be required. UDDI registry is not mandatory, as the service provider can directly provide information of WSDL file through email attachment.
4. After that, client generates the classes called STUB using STUB generation Tool. Another name for STUB is called proxies.
5. If client application is C++, then the stub is a C++ classes. The client stub’s method implementation is different that server’s service class methods.
6. Client application creates a new stub object. On the top of this stub, it will invoke the method and get the result.
7. STUB will store and prepare parameter values, parameter datatypes in the form of XML document, in web service it is called SOAP request.
8. It is called SOAP request because STUB uses some predefined tags of SOAP.
9. HTTP protocol will move SOAP request from client to server location.
10. Server will handover to SKELETON. SKELETON is a predefined classes which depends on service class.
11. SKELETON will actually invokes the service class and gets the return value. SKELETON will again prepare one XML document called SOAP response with predefined tags from the SOAP.
12. HTTP protocol will move SOAP response from server to client location because HTTP is transportation protocol, which transports information from one location to another location.
13. SOAP response is available at the client location. The response will be read by STUB and will be handover to this client.
14. SOAP is, therefore, called messaging protocol.

SUN Microsystem has provided four API for webservice:

These are all webservice specification provides interfaces and abstract classes. So, it requires separate webservice implementation.

JAX-RPC:

JAX-WS:

JAX-RS:

JAX-M:

Developing Webservice in Eclipse :

1. First and foremost, we need to add tomcat server or other server for developing webservice in Eclipse.
2. We create Dynamic Web Project
3. We create service class (POJO class).
4. Convert service class to webservice using Axis1 implementation.
5. Eclipse supports only Axis1, Axis2 and CFX implementation.

Developing webservice client eclipse:

1. Two types of client
2. Proxy based client: Client generates STUB at client side.
3. DII(Dynamic Invocation Interface) based client: Client never generates STUB
4. Physical WSDL file or WSDL URL , we can create webservice client to invoke webservices.
5. Create Java Project
6. Copy WSDL file into project
7. Generates stubs
8. Create TestClient.java, containing main method.

Developing Webservice Using Axis2:

1. Download Axis2 jars and extract downloaded jars some where in our systsm
2. Add Axis2 jars to eclipse
3. Create Dynamic Web Project with project name is Axis2CalService.
4. Create MathService.java src folder with com.test.service package
5. Convert MathService.java into webservice using Axis2 implementation.
6. Test whether service is deployed or not in server.

Developing webservice client using axis2:

1. Create Dynamic Web Project with project name Axis2CalServiceClient
2. Generate stubs in src folder
3. Create TestClient.java