使用Java快速实现,部署Web服务 [英] Quickly implement, deploy a Webservice in Java

查看:163
本文介绍了使用Java快速实现,部署Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C ++,Java,Python混合编写的大型系统。我必须使用webservice技术将这个系统的一小部分与一个门户网站连接起来。 Web服务并不重要,它必须公开3或4种方法。

I have a large system written in a mixture of C++, Java, Python. I have to interface a very small subset of this system with a web portal using webservice technology. Webservice is not critical and it has to expose 3 or 4 methods.

今天在Java中实现这一点的最快方法是什么?我考虑过AXIS + Tomcat。也许还有其他最新的库?

What is today the quickest way to implement this in Java? I thoughted AXIS+Tomcat. Maybe is there any other newest library?

推荐答案


今天最快的方法是实现这个Java的?我考虑过AXIS + Tomcat。也许还有其他最新的图书馆?

What is today the quickest way to implement this in Java? I thoughted AXIS+Tomcat. Maybe is there any other newest library?

是的,还有更好的方法。忘记Axis并转到JAX-WS堆栈,例如 JAX-WS RI (这是包含在Java 6)或 Apache CXF 中。以下是常用的HelloWorld服务,其中包含使用JDK内置HTTP服务器的测试方法:

Yes, there is a much better way. Forget Axis and go for a JAX-WS stack such as JAX-WS RI (which is included in Java 6) or Apache CXF. Here is the usual HelloWorld service with a test method using the built-in HTTP server of the JDK:

package hello;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService
public class Hello {
    @WebMethod
    public String sayHello(String name) {
        return "Hello, " + name + ".";
    }

    public static void main(String[] args) {
        Endpoint.publish("http://localhost:8080/WS/Hello", new Hello());
    }
}

只需运行 main 方法,您已准备好使用Web服务。

Just run the main method and you're ready to play with the web service.

当然,您需要在真实容器上部署Web服务以供生产使用。您可以使用GlassFish并只部署您的服务(GlassFish捆绑JAX-WS运行时)。或者您可以选择Jetty或Tomcat并在其上安装所选的运行时(JAX-WS RI或Apache CXF)。请参阅各自的说明。

Of course, you'll want to deploy your web service on a real container for production use. You could go with GlassFish and just deploy your service (GlassFish bundles a JAX-WS runtime). Or you could pick Jetty or Tomcat and install the chosen runtime on it (JAX-WS RI or Apache CXF). Refer to their respective instructions.

  • Creating a Simple Web Service and Client with JAX-WS
  • JAX-WS Five Minute Tutorial
  • Getting started with JAX-WS...

这篇关于使用Java快速实现,部署Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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