Java:使用端点将 webservice 发布到 tomcat 服务器 [英] Java: using endpoint to publish webservice to tomcat server

查看:29
本文介绍了Java:使用端点将 webservice 发布到 tomcat 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个简单的 SOAP Web 服务.我要确保它在 tomcat 网络服务上运行.

i am creating a simple SOAP web service. i am to ensure that it runs on a tomcat web service.

我试图用 JAX-WS 来实现这个(见代码)

im trying to implement this with JAX-WS (see code)

我的问题是:Endpoint.publish 是使用 tomcat 服务器来托管它还是它是一种 mini glassfish 类型的服务器?

my question is: does the Endpoint.publish use the tomcat server to host this or is it a mini glassfish kind of server?

我应该扩展 UnicastRemoveObject 或类似的东西吗?

should i be extending UnicastRemoveObject or something similiar instead?

理想情况下,它可以打包成 .WAR 文件并放入目录中并正常工作.

ideally it would be able to be packaged into a .WAR and dropped in the directory and just work.

它似乎不适用于我安装的 tomcat 服务器,因为它说端口已被使用.我正在使用安装了 tomcat6 软件包的 Ubuntu karmic,也可能是我的用户没有发布到 8080 上正在运行的 tomcat 的权限

It doesn't seem to work with my installed tomcat server as is because it says the port is already in use. I'm using Ubuntu karmic with the tomcat6 package installed, it could also be my user doesnt have permissions to publish to the running tomcat on 8080

我希望这个问题足够清楚

i hope this question is clear enough

示例代码:

@WebService
public class UserAttributes {
    public static void main(String[] args) {
        UserAttributes instance = new UserAttributes();
        Endpoint.publish("http://localhost:8082/WebServices/userattributes", 
            instance);
    }

    public string Hello() {
       return "Hello World";
    }
}

推荐答案

Endpoint.publish 是使用 tomcat 服务器来托管这个服务器还是一个 mini glassfish 类型的服务器?

Does Endpoint.publish use the tomcat server to host this or is it a mini glassfish kind of server?

JAX-WS RI Endpoint.publish API 默认使用轻量级的 HTTP 服务器实现 包含在 Sun 的 Java SE 6 中.所以不,它使用嵌入式 GlassFish 或嵌入式 Tomcat,更不用说您现有的 Tomcat 安装:它使用一个嵌入式 容器,即在同一个 JVM 中运行的东西.仅供参考,但是只要它们提供服务提供者实现 (SPI),就可以插入其他实现.例如,Jetty 6 这样做,请参阅 J2se6HttpServerSPI.但我不会在这里涵盖所有细节:)

JAX-WS RI Endpoint.publish API uses by default a light-weight HTTP server implementation that is included in Sun's Java SE 6. So no, it does not use an embedded GlassFish nor an embedded Tomcat and even less your existing Tomcat install: it uses an embedded container i.e. something running inside the same JVM. Just FYI, it is however possible to plug other implementations as long as they provide a Service Provider Implementation (SPI). For example, Jetty 6 does so, see J2se6HttpServerSPI. But I'm not going to cover all the details here :)

它似乎不适用于我安装的 tomcat 服务器,因为它说端口已被使用.

It doesn't seem to work with my installed tomcat server as is because it says the port is already in use.

正如我上面所说,Enpoint.publish API 不使用您现有的 Tomcat 安装.它使用自己的服务器,允许您部署 Web 服务而无需打包和部署您的应用程序.它在开发过程中特别有用(因为它可以加快速度).实际上,它非常方便.

As I said above, the Enpoint.publish API doesn't use your existing Tomcat install. It uses its own server and allows you to deploy your web service without having to package and deploy your app. It is especially useful during development (as it speeds up things). Actually, it's extremely handy.

现在,如果您的 Tomcat 服务器在端口 8082 上运行,并且如果您尝试使用相同的端口发布您的 Endpoint,事情将不会像您注意到的那样工作.在开发过程中使用不同(且未使用)的端口.

Now, if you have a Tomcat server running on port 8082 and if you try to publish your Endpoint using the same port, things won't work as you noticed. Use a different (and unused) port during development.

如果您想将您的 Web 服务部署到您现有的 Tomcat 安装中,那么您必须将它们打包在一个 war 中并在 Tomcat 上部署这个 war.但这完全不同,与使用 Endpoint.publish API 没有任何关系.

And if you want to deploy your web services to your existing Tomcat install, then you'll have to package them in a war and to deploy this war on Tomcat. But this is totally different and doesn't have anything to do with using the Endpoint.publish API.

这篇关于Java:使用端点将 webservice 发布到 tomcat 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆