1.以下为具体实现类
1.
2.IWebService类
2.WebServiceImpl
@WebService
public class WebServiceImpl implements IWebService {
@Override
public String inwebsrvice(String name) {
Date date = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String hello = df.format(date) + "," + name + "call the inferface!";
return hello;
}
3。WebServiceCalledByServlet
@WebServlet(value="", loadOnStartup=0)
public class WebServiceCalledByServlet extends HttpServlet {
private static final long serialVersionUID = -2864381365175258589L;
public void init() {
String address = "http://192.168.23.97:8889/WebServiceWithServlet";
Endpoint.publish(address, new WebServiceImpl());
System.out.println("使用WebServiceCalledByServlet发布webservice成功!");
}
发布成功如下,注意加?wsdl