Deploy java web service without using web server

泪湿孤枕 提交于 2019-12-28 05:29:11

问题


It is possible to deploy my own created web service to any of PC without installing any web server app eg:tomcat? I want make it like agent/plug-in in any PC. In order to access the web services i only need to access http://:8080/web_service. Any suggestion about this?


回答1:


Even lighter than running Jetty you can use the HttpServer built into Java.

http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/package-summary.html

You'll need to write your own code for parsing request data but it's certainly doable.

http://blogs.operationaldynamics.com/andrew/software/free-java/sun-secret-webserver.html




回答2:


Take a look at Jetty, a very light servlet container




回答3:


Take a look at Apache CXF. It can use jetty for stand-alone web-services. It integrates with Spring which makes it easy to add a web-service simply as spring-bean with very little additional code.




回答4:


You will need something listening for a http connection. Fortunately Java 6 has all you need in the default runtime.

Have a look at:

http://hofmanndavid.blogspot.com/2008/11/easiest-way-to-publish-java-web.html




回答5:


You mention Tomcat as an example of what you don't want to do, but Tomcat can be run in embedded mode, where it gets started up from inside your application:

http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/catalina/startup/Embedded.html

Saying that, I'd recommend Jetty, it's more light-weight than Tomcat.




回答6:


same question with Lightweight Webservice producing in Java (without an application server)

javax.xml.ws.Endpoint.publish("http://localhost:8000/myService/", myServiceImplementation);



回答7:


I think Spring web services can be configured to run in a "fake" web server as well - there is a discussion on this on spring web services forum for sure (I needed the same thing, but ended up using a web server due to other issues)




回答8:


I've been following this pretty basic tutorial, and it does just what you want

http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/

It seems like the Java SE 6 platform has a small web application server that will publish the web service while the JVM is running.




回答9:


A perfect solution is here from IBM

https://www.ibm.com/developerworks/webservices/tutorials/ws-jse/



来源:https://stackoverflow.com/questions/1292171/deploy-java-web-service-without-using-web-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!