1.創(chuàng)建要發(fā)布的類
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.發(fā)布服務
package com.test.webserive;import javax.xml.ws.Endpoint;public class Service { public static void main(String[] args){ /** * 參數1:服務器的發(fā)布地址 * 參數2:服務的實現(xiàn)者 */ Endpoint.publish("http://10.90.2.17:6789/hello", new HelloServiceImpl()); System.out.3.啟動運行,打開瀏覽器輸入
http://10.90.2.17:6789/hello?wsdl看到下面文件即成功發(fā)布:
新聞熱點
疑難解答