Conversion of POJO’s into Web-Services
SOA: SOA is the abbreviation for Service Oriented Architecture. It is one of the programming styles by which one can create/use and expose the services over a network.
Why do we need SOA?
The world is expanding with knowledge, in the form of data; there is an immense need for few of the legacy applications to be in phase with the new worlds data. Programmers face difficulty in maintaining and updating these legacy applications due to various reasons like internal dependencies, language obscurity, etc… In such a case, SOA seems to be an auxiliary tool which can void the programmer’s night-mare.
Using SOA programmer’s can program in such a way that the legacy system can be in phase with the new technology. SOA does this miracle by sandwiching the new technology and the legacy application with a thin layer which can interact between the two entities.
Not only in case of the legacy applications, SOA show’s it’s commanding position even in case of new technologies/ applications. Whenever two or more application needs to exchange the data, SOA provides a bridge between the applications, which overlays one of the programming challenge language dependency.
What do we achieve by implementing SOA?
By using SOA programmers can easily configure two or more application to interact and to exchange the data.
Which are the different approaches to implement SOA?
There are two approaches to implement SOA:
Top Down approach: in this approach the programmers integrate the SOA structure for the existing application by creating a wrapper layer which interacts between the applications. This approach is usually used only when SOA needs’ to be integrated to the existing systems.
Bottom up approach: in this case the programmers code the application, by keeping a view in the mind that the services being coded will be exposed as a service over the network. This approach is usually followed while developing a new application.
Concerns to be accounted while implement SOA:
While implementing SOA, there is a requirement for the service provider and the service consumer to agree upon the data format being exchanged across the applications.
Security is the main concern which has to be taken care off. Whenever a service is exposed, the system should be intelligent enough to know the consumer’s consuming the service and to log the transactions. As well as, system should expose the service only for the legitimate consumers, System should be protected from the hackers.
Apache Tomcat Server / JBoss.
Configuring Eclipse for Axis2 plug-ins:
1) Download Axis2 plug-ins:
2) Unzip the files into eclipse plug-in folder.
Configuring Apache Tomcat server with Axis2 plug-in:
1) Download the plug-in:
2) Unzip the file into \webapps folder which is present in Apache Tomcat installed directory.
3) To confirm whether the Apache Tomcat Server is configured with Axis2, hit the URL: http://localhost:8080/axis2/ .
The below shown page should appear.
Conversion of POJO’s into Web-Services:
Once Eclipse and Server are configured, the next step will be to identify the services which you will be exposing as Web-Services.
Decide whether a wrapper class is required to expose the service, if required code the wrapper class then, proceed to step 3 to create Axis Archived file (.aar file).
Compile the class to generate the .class files.
- Right click on the “Package Explorer” window on Eclipse. Then follow the path
New > Other > Axis2 Wizard. Then click on next.
- Select the directory where the .class files for the services are present.
Check the “Skip WSDL” check-box.
Add the entire jar’s which will be required to generate the .aar files.
If the archive file requires any service XML files it can include. Else select the “Generate the service xml automatically” checkbox.
Load the class file and select the methods which you will be exposing as a web-service.
Select the output location where the .aar file, is to be generated.
When you click finish, wait for the confirmation message.
The .aar file will be successfully generated.
II. Deploying .aar file into Tomcat server using Axis2 service provider:
Login into the axis2 server by accessing the URL: http://localhost:8080/axis2/axis2-admin/
Click on “upload service”
Select the .aar file and click on “upload” button.
Wait for the conformation message!
To confirm the service is uploaded hit the url: http://localhost:8080/axis2/services/listServices
This confirms that the service is deployed successfully.
Finally, make sure that the library files which will be required for the service to work are deployed in lib directory.
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis2\WEB-INF\lib
Testing of the service using .net Client:
Add the web reference by following the path:
ProjectAdd web References.
Add the web reference by selecting the URL on which the web service is hosted:
Write the client code.
Run the code to see the output:
@ .net Client – Courtesy – Deepesh P C – NTL Bangalore.