webservice中jaxws:server和jaxws:endpoint的区别
答案:2 悬赏:70
解决时间 2021-11-26 00:17
- 提问者网友:不懂我就别说我变
- 2021-11-25 12:55
webservice中jaxws:server和jaxws:endpoint的区别
最佳答案
- 二级知识专家网友:努力只為明天
- 2021-11-25 14:10
变量设置的有问题吧
全部回答
- 1楼网友:不羁的心
- 2021-11-25 15:06
java 中的 web service 分为基于 soap 的和基于 rest 的两种,下面简单说一个基于 soap 的例子。要使用 jdk6u4 之后的版本才能编译通过。
先编写一个 web service 的接口:
@webservice
@soapbinding(style = style.rpc)
public interface timeserver {
@webmethod string gettimeasstring();
@webmethod long gettimeaselapsed();
}
再编写 web service 实现:
import java.util.date;
import javax.jws.webservice;
@webservice(endpointinterface = "test.timeserver")
public class timeserverimpl implements timeserver {
public string gettimeasstring() { return new date().tostring(); }
public long gettimeaselapsed() { return new date().gettime(); }
}
最后启动 web service:
public class timeserverpublisher {
public static void main(string[ ] args) {
endpoint.publish("", new timeserverimpl());
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯