使用jdk 1.6的Web服务

时间:2011-04-22 07:07:58

标签: java web-services

大家好 我是网络服务的新手。我写了一个java类。 但我没有得到如何部署它。我的意思是我需要Web服务器或应用服务器。由于这是简单的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);

1 个答案:

答案 0 :(得分:1)

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