What is Axis?
Axis is essentially a SOAP engine - a framework for constructing SOAP processors such as clients, servers, gateways, etc. The current version of Axis is written in Java, but a C++ implementation of the client side of Axis is being developed.
But Axis isn't just a SOAP engine - it also includes:
- a simple stand-alone server,
- a server which plugs into servlet engines such as Tomcat,
- extensive support for the Web Service Description Language (WSDL),
- emitter tooling that generates Java classes from WSDL.
- some sample programs, and
- a tool for monitoring TCP/IP packets.
Minimum steps to expose a method as AXIS web service
Besides the libraries configurations (refer to documentation on
AXIS site at
http://ws.apache.org/axis/index.html ), here are few things that need to happen as a minimum for
AXIS web services.
web.xml
<!-- Apache Axis 1.1 Servlet definitions -->
<servlet>
<servlet-name>AdminServlet</servlet-name>
<display-name>Axis Admin Servlet</display-name>
<servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
</servlet>
<!-- Apache Axis 1.1 Servlet Mappings -->
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>uapexternaltoolsservlet</servlet-name>
<url-pattern>/uapexternaltoolsservlet</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>htc</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wsdl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsd</extension>
<mime-type>text/xml</mime-type>
</mime-mapping> <!-- End of Apache Axis 1.1 Servlet Mappings -->
WEB-INFserver-config.wsdd
…
<service name="MetricsImport" provider="java:RPC">
<parameter name="allowedMethods" value="getCampaignMetrics"/>
<parameter name="className" value="com.custommode.SimulateMetricsImportService"/>
</service>
...
SimilateMetricsImportService.java
/*
* Created on Oct 1, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.custommode;import com.custommode.logger.UALogger;/**
* @author damelchenko
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class SimulateMetricsImportService { private static UALogger log = (UALogger) UALogger
.getLogger(SimulateMetricsImportService.class);
public String getCampaignMetrics(String campainId) {
log.access("received a request for " + campainId + " campainId");
return
"<?xml version="1.0" encoding="UTF-8"?><CampaignServiceResponse><metric-data><metric id="contactcount" value="10000"/><metric id="responsecount_email" value="1000"/><metric id="responsecount_clicks" value="1500"/><metric id="responsecount_purchases" value="199"/><metric id="responsecount_directmail" value="2"/></metric-data></CampaignServiceResponse>"; }
}
Client example code.
// make a call to the web service
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(serviceUrl));
call.setOperationName(new QName("http://soapinterop.org/",
"getCampaignMetrics"));
Object result = call.invoke(new Object[] { new Integer(_projectid).toString() });