Java不使用web容器,发布WebService应用
文章转自:http://www.cnblogs.com/lixyvip/archive/2012/04/07/2436608.html
可以做到不借助web容器(如GlassFish或者Tomcat)发布WebService应用
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()); } }
生成客户端调用类
wsimport-keep-Xnocompilehttp://127.0.0.1:8088/JavaAppWebService?wsdl
相关推荐
lantingyue 2020-07-30
丽丽 2020-10-30
一青年 2020-08-13
yuanye0 2020-06-21
akcsdno 2020-06-15
Julywhj 2020-06-09
MrFuWen 2020-06-06
neweastsun 2020-03-30
kong000dao0 2020-03-07
JayFighting 2020-02-24
mokingone 2012-09-03
六天 2013-05-13
数据库工具开发 2013-05-10
书弋江山 2020-01-14
SoarFly00 2020-01-14
akcsdno 2020-01-04
htofly 2020-01-04
yuanye0 2020-01-04
CoderBoy 2019-12-30