https://www.cnblogs.com/AlanLee/archive/2017/06/02/6933073.html 1、普通java pro 新建: package com.busy.webservice;import javax.jws.WebService;import javax.xml.ws.Endpoint;@WebServicepublic class WebServiceTest {public String transWor
https://www.cnblogs.com/AlanLee/archive/2017/06/02/6933073.html
1、普通java pro 新建:
package com.busy.webservice; import javax.jws.WebService; import javax.xml.ws.Endpoint; @WebService public class WebServiceTest { public String transWords(String words) { String res = ""; for (char ch : words.toCharArray()) { res += ch + ","; } return res; } public static void main(String[] args) { // 使用Endpoint(终端)类发布webservice Endpoint.publish("http://localhost:8089/service/webservice", new WebServiceTest()); System.out.println("Publish Success"); } }
2、可以用测试工具测试:Storm_r1.1-Adarna
3、java webservice client,先用jdk自带的 wsimport 生成代码
wsimport -s . http://localhost:8089/service/webservice?wsdl
4、新建普通java pro,引入生成的java 文件
5、直接调用:
package com.busy.webservice; public class MainTest { public static void main(String[] args) { WebServiceTestService test = new WebServiceTestService(); WebServiceTest tes = test.getPort(WebServiceTest.class); String self = tes.transWords("娃哈哈"); System.out.println(self); } }