Saturday, November 3, 2012

Java SOAP Web Service With Apache Axis2 in Netbeans

<

Requirements

  1. Java Development Kit (JDK)

  2. NetBeans IDE

  3. Apache Axis 2

  4. Apache Tomcat Server


Main Topics

  1. Setup Development Environment

  2. Create Web Service

  3. Deploy Web Service to Tomcat Server


1. Setup Development Environment


Install Axis2 Support Plugin


Go to Tools >> Plugins and open Plugin Manager. Check whether Axis2 Support Plugin is already installed. Otherwise you may need to find it from Available Plugins and install.


Configure Axis2 for Tomcat


Extract axis2.war archive to Tomcat webapps directory.

You can find this directory in your CATALINA_BASE/webapps. If you are not sure where CATALINA_BASE points to, open Services tab and select Tomcat server. Right click Tomcat server and select properties. Most probably you will find it there. If there is no CATALINA_BASE, you have not run your Tomcat before. Start and stop Tomcat to allow this varible generate.



Start or restart the Tomcat server. Tomcat unpacks the axis2.war file into an axis2 folder in CATALINA_BASE/webapps.

Go to Tools >> Options and click Axis2 icon to view deployment options. Set the target location for Axis2 AAR files to your CATALINA_BASE (not TOMCAT_HOME)/ webapps/axis2 directory.

Make sure the Axis2 URL field contains the correct port number for your Tomcat server. To check the port number, start Tomcat (from the Services tab or from Tools -> Servers) and see what port Coyote HTTP/1.1 uses.

select Use Tomcat Manager for Deployment

Check whether username and password of manager role are correct by referring CATALINA_BASE/conf/tomcat-users.xml.


2. Create Web Service


File >> New Project. The New Project wizard opens. From the Java category, select a Java class library project. Click Next.

Right-click the project and choose New >> Other. The New File wizard opens. From the Web Services category, choose Axis2 Service from Java and click Next.



Keep settings as it is in the following wizard and click Next.


In this wizard enter Java Web Service class name and click Finish.


The IDE generates a HelloAxisWorld.java class in the axishello source package and a HelloAxisWorld Axis2 web service that mirrors this Java class.


3. Deploy Web Service to Tomcat Server


Right-click the web service's node. The context menu opens. Select Deploy to Server. The IDE compiles an Axis2 AAR file and copies it to the axis2.war file used by the application server.

If you enabled automatic deployment in Tomcat Manager, axis.war will automatically redeploy to server whenever it 's get updated.

To test the service, expand the web service node to reveal the operations. Right-click the hello:String node and select Test Operation in Browser.

To test the service, expand the web service node to reveal the operations. Right-click the hello:String node and select Test Operation in Browser.

Browser opens with a test value of your variables. You can find test value in the URL. Change it and refresh the page.

 

9 comments:

  1. Muito bom post!
    Estava travado a dias no problema e consegui soluciona-lo.
    Parabéns.

    ReplyDelete
  2. […] tried everything in this tutorial‚ But when it cam time to deploy the web service i got this […]

    ReplyDelete
  3. Why i am getting this, even though i have set that as you told

    Neither deployment directory nor war file specified for Axis2 web application (Axis2 environment).
    Please, specify the axis2.war or axis2 deployment directory location in

    Tools -> Options -> Axis2 -> Deployment panel.

    ReplyDelete
  4. Why i am getting this . even though i have set that.

    Neither deployment directory nor war file specified for Axis2 web application (Axis2 environment).
    Please, specify the axis2.war or axis2 deployment directory location in

    Tools -> Options -> Axis2 -> Deployment panel.

    ReplyDelete
  5. I am getting the same error as Latif Khan ("Neither deployment directory nor war file specified for Axis2 web application"). I'm using Netbeans 7.4. I set-up a clean tomcat 7.0.41, put the axis2.war in {CATALINA_HOME}\webapps. I started Tomcat from within netbeans, and can see axis2 in the application list, can open axis2 it in a browser from there, and even get the axis2 happiness page, so it seems like Netbeans and Axis2 have been properly introduced. In Tools->Options->Axis2, I'm using {CATALINA_HOME}\webapps\axis2.war for the Target Location for Axis2 .aar Files. I pasted the working URL from my browser to the URL, and double-triple-quadruple checked the Username and Password for deployment. Still getting that error when I try to deploy the HelloAxisWorld web service. At my wits end...any ideas?

    ReplyDelete
  6. how to generate web service client using axis 2

    ReplyDelete
  7. For those who are looking after a fix to the error "please specify (...) under Tools", you can read the following article : http://vincent-lecomte.blogspot.be/2014/10/java-probleme-config-axis2-et-netbeans.html (in French). You have to create the properties file that stores the configuration because NB 7.4 seems not able to do it for you, even in administrator mode. I don't know if this works for the newer versions.

    ReplyDelete
  8. Its worked for me in NetBeans7.3.1 only

    ReplyDelete

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...