1.创建要发布的类
package com.test.webserive;import javax.jws.WebService;//targetNamespace定义命名空间@WebService(targetNamespace="http://www.mess.com")public class HelloServiceImpl { public String sayHello(String name){ return "Hello:"+name; } public String syaHi(String username){ return "Hi:"+username; }}
2.发布服务
package com.test.webserive;import javax.xml.ws.Endpoint;public class Service { public static void main(String[] args){ /** * 参数1:服务器的发布地址 * 参数2:服务的实现者 */ Endpoint.publish("http://10.90.2.17:6789/hello", new HelloServiceImpl()); System.out.PRintln("Server ready..."); }}
3.启动运行,打开浏览器输入
http://10.90.2.17:6789/hello?wsdl看到下面文件即成功发布:
新闻热点
疑难解答