java - 使用 jdk 1.6 的 Web 服务

标签 java web-services

大家好 我是网络服务新手。我写了一个java类。 但我不知道如何部署它。我的意思是我需要网络服务器还是应用程序服务器。由于这是简单的 java 类,我无法制作 WAR 文件来部署它。那么部署它的方法是什么以及我应该使用哪个服务器。我使用的是 JDK 1.6

  import javax.jws.WebService;
    import javax.jws.soap.SOAPBinding;
    import javax.jws.soap.SOAPBinding.Style;
    import javax.xml.ws.Endpoint;

    @WebService
    public class WiseQuoteServer {
    @SOAPBinding(style = Style.RPC)
    public String getQuote(String category) {
        if (category.equals("fun")) {
            return "5 is a sufficient approximation of infinity.";
        }
        if (category.equals("work")) {
            return "Remember to enjoy life, even during difficult situatons.";
        } else {
            return "Becoming a master is relatively easily. Do something well and then continue to do it for the next 20 years";
        }
    }

    public static void main(String[] args) {
        WiseQuoteServer server = new WiseQuoteServer();
        Endpoint endpoint = Endpoint.publish(
                "http://localhost:9191/wisequotes", server);

最佳答案

您问题的最佳答案是 tutorial of JAX-WS

关于java - 使用 jdk 1.6 的 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5753093/

相关文章:

java - 尝试减少 java 游戏中的内存分配 - 对于迭代器

Java - 泛化不同的类,相似的方法(不改变子类?)

objective-c - 使用 AFNetworking 使用 Web 服务发送音频

web-services - 如何在JBoss 7中启用SOAP消息的漂亮日志记录

java - 如何在 fragment 中声明适配器?

java - 分割和词干后正确的字符串格式

java - 优化 : Oj algorithms (java) versus SCIP (python)

java - 通过 GET 查询访问 Web 服务的简单方法?

c# - 如何检查exe的版本兼容性?

c# - 无法加载文件或程序集 'System.Private.ServiceModel,版本 = 4.1.2.4