既然要實現WebService,首先先來創建一個Service類
package cn.happy.webservice;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService
public class Service {
public void say(String name){
System.out.println("Hello"+name);
}
public static void main(String[] args) {
Endpoint.publish("http://localhost:50000/hello", new Service());
System.out.println("server is listening ....");
}
}
根據上面創建的服務http://localhost:50000/hello添加?wsdl去解析一些關鍵類


在提出一個測試類
package test;
import cn.happy.service.Service;
import cn.happy.service.ServiceService;
public class MyTest {
/**
* @param args
*/
public static void main(String[] args) {
ServiceService service=new ServiceService();
Service port=service.getServicePort();
port.say("好好好");
}
}
另外還有一些連接別的service服務的方式

選取wsdl

也可以直接通過http://192.168.15.54:50000/hello去網頁訪問,