How do I Embed SimpleHTTPServer in My Application and Deploy a POJO?
Submitted on May 8, 2006 - 19:01. Story : Project :
Q: How do I Embed SimpleHTTPServer in My Application and Deploy a POJO?
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! EmbeddedAxis2Server.java
import org.apache.axis2.context.ConfigurationContext;Echo.java
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");
context.getAxisConfiguration().addService(service);
SimpleHTTPServer server = new SimpleHTTPServer(context, 8080);
server.start();
}
}
package samples;
public class Echo {
public String echo(String in) {
return in;
}
}
Applies To:
Apache Axis2/Java 1.0 and above (2 votes)
»
- Login or register to post comments
- Printer friendly version
- 6321 reads
Tag Cloud
Apache
Apache Rampart
Apache Synapse
Axis2
Axis2
Axis2/C
WSF/C
Rampart/C
Axis2/C
data services
ESB
ESB
ESB/Java
Synapse/Java
Axis2/Java
Rampart/Java
AXIOM/Java
Sandesha2/Java
WSAS/Java
Mashup Server
Mule
OpenID
open source
PHP
WSF/PHP
POJO
Proxy Services
rampart
Rampart
Registry
REST
Sandesha2
security
SOA
soap
Synapse
Synapse
Training
webinar
Web Services
WS-Security
WSAS
WSAS
wsdl
wsf
WSF/C
WSF/PHP
WSO2
WSO2 Registry
WSO2 WSF/PHP










Axis2 with Jetty embedded server and POJO deployment
Very very helpful article!
I m newbie at Axis2 and Jetty.
I want to use Axis2 with Jetty embedded server and to deploy POJO programmatically. Jetty has nothing to do with type "ConfigurationContext" as SimpleHTTPServer do.
"SimpleHTTPServer server = new SimpleHTTPServer(context, 8080);"
How can I let jetty know about "ConfigurationContext". As, without "ConfigurationContext" one can't deploy a POJO programmatically.
Moreover Jetty is supposed to run Axis2 without Axis and webapps folder, as it is working in "EmbeddedAxis2Server".
Thanx.
AxisService.createService: bad signature
Tanks a lot for this very good article.
Just one comment: I'm using Axis 2 v1.4, and the "createService" method of the "AxisService" object has a different signature:
public static AxisService createService(String implClass, AxisConfiguration axisConfiguration, Map messageReceiverClassMap, String targetNamespace, String schemaNamespace, ClassLoader loader) throws AxisFault
Then the receiver must be put into the Map Object to be usable. Consequently, the new code is:
ConfigurationContext context = ConfigurationContextFactory
.createConfigurationContextFromFileSystem(null, null);
Map<String, MessageReceiver> mrMap = new HashMap<String, MessageReceiver>();
mrMap.put("http://www.w3.org/2004/08/wsdl/in-only",
RPCMessageReceiver.class.newInstance());
AxisService service = AxisService.createService(HelloWorldImpl.class
.getName(), context.getAxisConfiguration(), mrMap, "",
"http://samples", Main.class.getClassLoader());
context.getAxisConfiguration().addService(service);
SimpleHTTPServer server = new SimpleHTTPServer(context, 8080);
server.start();