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

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

问题描述

我正在创建一个简单的SOAP Web服务。
i am以确保它在tomcat Web服务上运行。

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服务器来托管这个或者它是一种迷你玻璃鱼类服务器?

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服务器来托管它还是微型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服务器实现。所以不,它使用嵌入式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.

现在,如果你有一个在端口8082上运行的Tomcat服务器,并且你试图发布你的端点使用相同的端口,事情将无法正常工作。在开发过程中使用不同的(未使用的)端口。

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安装,那么您必须将它们打包到战争并在Tomcat上部署这场战争。但这完全不同,与使用 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天全站免登陆