Axis2
Axis2, which implements but also extends JAX-WS, is an alternative to the Metro implementation. The current version is 1.6.x. Axis2 can be downloaded in various formats, including as a self-contained WAR file, axis2.war, which can be copied to TOMCAT_HOME/webapps. An Axis2 service does not require annotations if the proper configuration file is used. This section introduces Axis2 using a deliberately simple service so that the focus is on the deployment steps.
The HiService class (see Example 5-15) is a POJO class, free of annotations, that implements the SOAP-based HiService in
Axis2. Any public instance method in the class is thereby a service operation; in this case,
there is a single operation: echo.
Example 5-15. The HiService in Axis2
packagehello;publicclassHiService{// servicepublicStringecho(Stringname){// service operationStringmsg=(name==null||name.length()<1)?"Hello, world!":"Hello, "+name+"!";returnmsg;}}
The configuration file services.xml (see Example 5-16)
specifies that an instance of the Axis2 class RPCMessageReceiver will act as the
interceptor for requests against the operation named echo.
The configuration
document services.xml must be deployed in the JAR file’s META-INF directory.
Example 5-16. The services.xml configuration file for the Axis2 HiService
<service><parametername="ServiceClass"locked="false">hello.HiService</parameter><operationname="echo"><messageReceiverclass= "org.apache.axis2.rpc.receivers.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access