WSO2Con 2013 CFP Banner

How do I Embed SimpleHTTPServer in My Application and Deploy a POJO?

By Davanum Srinivas
Date: Mon, 8th May, 2006
Reads: 23675 Discuss this article on Stack Overflow

Q: How do I Embed SimpleHTTPServer in My Application and Deploy a POJO?

Davanum Srinivas

WSO2 Inc.

A: Without much ado, here's the EmbeddedAxis2Server that shows how to add a SimpleHTTPServer in your application and deploys a web service from a plain ol' java class samples.Echo (also shown below). All you need to do is get the binary jars from Axis 1.0 Final distribution, compile the 2 classes below and voila! you have an embedded Axis2 server.

Once you have it running, you can view the runtime generated wsdl at http://localhost:8080/axis2/services/Echo?wsdl or the schema at http://localhost:8080/axis2/services/Echo?xsd Enjoy!

import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
import org.apache.axis2.transport.http.SimpleHTTPServer;
import samples.Echo;

public class EmbeddedAxis2Server {
public static void main(String[] args) throws Exception {
ConfigurationContext context = ConfigurationContextFactory.
createConfigurationContextFromFileSystem(null, null);
AxisService service =
AxisService.createService(Echo.class.getName(), context.getAxisConfiguration(),
RPCMessageReceiver.class, "", "http://samples");
SimpleHTTPServer server = new SimpleHTTPServer(context, 8080);
package samples;

public class Echo {
public String echo(String in) {
return in;

Applies To:

Apache Axis2/Java 1.0 and above
WSO2Con 2014