java webservice发布,Java:使用端点将webservice发布到tomcat服务器

i am creating a simple SOAP web service.

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

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

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

should i be extending UnicastRemoveObject or something similiar instead?

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

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

sample code:

@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";

}

}

解决方案

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 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 :)

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

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.

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.

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值