标签:ice 分享 es2017 log main 浏览器 auto src nts
package cn.ydq.ws; import javax.jws.WebMethod; import javax.jws.WebService; @WebService public interface WebServiceI { @WebMethod String sayHello(String name); @WebMethod String save(String name,String pwd); }
package cn.ydq.ws; import javax.jws.WebService; @WebService public class WebServiceImpl implements WebServiceI{ @Override public String sayHello(String name) { // TODO Auto-generated method stub return "hello,"+name; } @Override public String save(String name, String pwd) { // TODO Auto-generated method stub return "name="+name+",password="+pwd; } }
package cn.dyq.ws.test; import javax.xml.ws.Endpoint; import cn.ydq.ws.WebServiceImpl; public class WebServicePublish { public static void main(String[] args) { String address = "http://127.0.0.1:8989/WS_Server/WebService"; Endpoint.publish(address,new WebServiceImpl()); System.out.println("发布webservice成功!"); } }
以上是服务端的代码,那么我们如何在客户端去调用这两个方法呢?请看下面:
打开浏览器,进入到http://127.0.0.1:8989/WS_Server/WebService
进入到cmd命令窗口
就可以看见生成的代码了
package cn.ydq.ws.test; import cn.ydq.ws.WebServiceImpl; import cn.ydq.ws.WebServiceImplService; public class TestClient { public static void main(String[] args) { WebServiceImplService swis = new WebServiceImplService(); WebServiceImpl wsi = swis.getWebServiceImplPort(); String rs = wsi.sayHello("dengyuanqi"); System.out.println(rs); } }
标签:ice 分享 es2017 log main 浏览器 auto src nts
原文地址:http://www.cnblogs.com/dengyuanqi/p/7722077.html