Publishing Simple Java class as Web Service using Axis

In Previous post on Axis(http://ydtech.blogspot.com/2009/06/deploying-apache-axis-to-oracle-oc4j.html), I have explained how to deploy Axis as a Web Application. Now its time to utilize Axis web service framework. Apache Axis provides a very simple way of publishing any simple java class as Web Service. This post explains it in simple steps.

1. Code your service implementation as a Simple java class. For this example we take example of simple String Conversation Service( lower case to upper case). This is only for demo purpose. Now Our pojo java class would be

public class StrConvService {
    public StrConvService() {
    }
    public String invoke(String str){
        return str.toUpperCase();
    }
}

2. Name this file as StrConvService.jws and copy it to <OC4J_Home>/jdev/home/application/<Axis_WebApp_Home>/<webapp>

3. Got to http://localhost:8888/axis-webapp/StrConvService.jws 

4. Click on WSDL link on this page. Here is the WSDL for our String Conversion Service.

5. We can test this using Jdeveloper. Create a simple Empty Project in jdeveloper and add a Web Service Proxy.

2009-06-28_1029.png

6. Give http://localhost:8888/axis-webapp/StrConvService.jws?wsdl as WSDL url and use all default settings.

2009-06-28_1025.png

7. At the end of this wizard, jdeveloper creates as Service client for you with proxy object initiated. You have to just invoke the Web Service method.

2009-06-28_1030.png

As shown in above screen shot , we have invoked String Conversion Service by calling “invoke” method and got result in upper case.

Now, how simple is publishing a Web Service! All complications of handling SOAP message is taken cared by Axis.

Comments

Popular posts from this blog

Composite Design Pattern by example

State Design Pattern by Example

Eclipse command framework core expression: Property tester