HOME | J2ME | Struts | AJAX | SOAP | SOA MEDIA STREAMING AXIS |
AXIS STEP BY STEP
Web Services
Axis Introduction
Installations
Hello World
Using Eclipse
POJO Service
POJO Client
AXIOM Service
AXIOM Client

 

 

POJO based Axis Service End Points

Back | Tutorial Home | Next

Now that we have gone through the rudimentary of a Hello World program, Time to start digging deeper. In this section we will explore following features of Axis using Address Book Example

  • Service end point internals
  • Service clients

Download Address Book source code discussed in this lesson.

Source code of AddressBook value object is given below. This class is a simple POJO with getter and setter methods for following data

  • First Name
  • Last Name
  • Phone Number
  • Address
package demo.data;

public class AddressBook{
    String firstName;
    String lastName;
    int phoneNumber;
    String address;
 
    public void setFirstName(String firstN){
        firstName = firstN;
    }

    public String getFirstName(){
        return firstName;
    }

    public void setLastName(String lastN){
        lastName = lastN;
    }

    public String getLastName(){
        return lastName;
    }
    
    public void setPhoneNumber(int phone){
        phoneNumber = phone;
    }

    public int getPhoneNumber(){
        return phoneNumber;
    }

    public void setAddress(String addr){
        address = addr;
    }

    public String getAddress(){
        return address;
    }
}

Now create a service class which is again a value object with get and set for AddressBook class

package demo.service;

import demo.data.AddressBook;

public class AddressBookService{
	AddressBook address;
    
    public void setAddressBook(AddressBook address){
        this.address = address;
    }

    public AddressBook getAddressBook(){
        return this.address;
    }
}
<service name="AddressBookService" scope="application">
	<description>Address Book 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">demo.service.AddressBookService</parameter>
</service>

The above xml describes following parameters for a service

  • The name of service is "AddressBookService"
  • The scope of this application is application wide
  • Message receivers(Message Exchange Patterns (MEPs) defined are
    - RPCInOnlyMessageReceiver for in-only method setAddressBook()
    - RPCMessageReceiver for in-out method getAddressBook()
  • The service class parameter is defined as demo.service.AddressBookService which defines the various operations or methods.

Apart from the message receivers mentioned above some of the other popular message receivers for other non POJO data bindings are

  • org.apache.axis2.receivers.RawXMLINOutMessageReceiver
  • org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver
  • org.apache.axis2.javaws.server.JAXWSMessageReceiver

Finally build the service using build file target “generate.service”. To get this target in Eclipse double click on the build.xml in the project explorer panel, all the ant build file targets will be visible in a new window called “outline”. Right click on “generate.service” and run as ant build. Upload the generated arr file to services folder of axis installation.

finnaly check the service availability in AXIS's service console. In the next section we will develop a service client to access Address Book service end point

Back | Tutorial Home | Next

site comments powered by Disqus
Download our free toolbar

toolbar powered by Conduit

| Copyright © 2009. All rights reserved | Terms and Conditions | About | Contact | Feed Back |