不使用web服务器部署java web服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1292171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 07:51:22  来源:igfitidea点击:

Deploy java web service without using web server

javaweb-services

提问by winsontan520

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?

可以将我自己创建的 Web 服务部署到任何 PC,而无需安装任何 Web 服务器应用程序,例如:tomcat?我想让它像任何 PC 中的代理/插件一样。为了访问网络服务,我只需要访问 http://:8080/web_service。对此有何建议?

回答by Ben

Take a look at Jetty, a very light servlet container

看看Jetty,一个非常轻的 servlet 容器

回答by laura

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)

我认为 Spring Web 服务也可以配置为在“假”Web 服务器中运行 - 肯定在 Spring Web 服务论坛上对此进行了讨论(我需要同样的东西,但由于其他原因最终使用了 Web 服务器问题)

回答by pjp

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

甚至比运行 Jetty 更轻松,您可以使用 Java 中内置的 HttpServer。

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

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

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

回答by Wolfgang

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.

看看Apache CXF。它可以将码头用于独立的网络服务。它与 Spring 集成,这使得添加 web 服务变得简单,只需很少的附加代码即可作为 spring-bean。

回答by skaffman

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:

您提到 Tomcat 作为您不想执行的操作的示例,但 Tomcat 可以在嵌入式模式下运行,从应用程序内部启动它:

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

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.

话虽如此,我还是推荐 Jetty,它比 Tomcat 更轻量级。

回答by Thorbj?rn Ravn Andersen

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

您将需要监听 http 连接的东西。幸运的是,Java 6 在默认运行时拥有您所需要的一切。

Have a look at:

看一下:

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

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

回答by opensas

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/

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.

Java SE 6 平台似乎有一个小型 Web 应用程序服务器,它将在 JVM 运行时发布 Web 服务。

回答by leef

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

Java 生成的轻量级 Web 服务的相同问题 (没有应用程序服务器)

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

回答by Vijay