现在的位置: 首页 > 综合 > 正文

Java不使用web容器,发布WebService应用

2013年02月08日 ⁄ 综合 ⁄ 共 817字 ⁄ 字号 评论关闭

可以做到不借助web容器(如GlassFish或者Tomcat)发布Web Service应用

 

 package com.tavenli.codesample.etlsmc;

import java.util.Date;

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

@WebService(targetNamespace = "http://www.TavenLi.com")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class JavaAppWebService {

    @WebMethod
    public String getServerTime()
    {
        //返回服务器时间的方法
        return new Date(System.currentTimeMillis()).toString();

    }

    public static void main(String[] args)
    {
        //可以做到不借助web容器(如GlassFish或者Tomcat)发布Web Service应用
        
//访问:
        
//http://localhost:8088/JavaAppWebService
        
//http://localhost:8088/JavaAppWebService?wsdl
        Endpoint.publish("http://localhost:8088/JavaAppWebService", new JavaAppWebService());
    }

}

 

 

抱歉!评论已关闭.