Hello World web wervice using Axis2

The goal of this lab is to develop a first example of a web service using Axis2. This is simply to display the famous: HELLO WORLD.

  1. Define the following directory/file structure:
    - helloService   
       - META-INF
           - services.xml   
       - hello
           - HelloWorld.java
  2. Define the HelloWorld.java service class:
    package hello;
     
    public class HelloWorld{
     
    	public String sayHello() {
    		return "Hello world!";
    	}
    }
  3. Define the deployment file services.xml as follows:
    <service name="HelloWorldService" scope="application">
        <description>
           Hello World  Service
        </description>
        <messageReceivers>
            <messageReceiver  mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
            <messageReceiver  mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
        </messageReceivers>
        <parameter name="ServiceClass">
            hello.HelloWorld
        </parameter>
    </service>
  4. Compile your program with javac HelloWorld.java
  5. Deploy the service on Axis2 by copying the helloService directory to AXIS2_HOME/repository/services/.
  6. You are now able to see the HelloWorldService service in the list of Axis2 services accessible on the page with the following URL: http://localhost:8080/axis2/services/. If you click on the HelloWorldService service link, you will see the WSDL definition (automatically generated by Axis2) of your web service.
  7. To run a method of your service and get the corresponding SOAP response, you type the following expression into your browser: http://localhost:8080/axis2/services/HelloWorldService/sayHello. Compared to the previous expression, you specify here the name of the method to be executed.
teaching_assistant/web_services/first_web_service_axis2.txt · Last modified: 2021/09/06 09:23 by Nour
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0