1 项目结构 (使用java方式,只需要jdk,不需要添加任何 jar 和依赖)
2 接口
public interface TestService{
String sayHello(String name);
}
3 实现类
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
@WebService
public class TestServiceImpl implements TestService{
@WebMethod
@WebResult(name = "resultName")
@Override
public String sayHello(@WebParam(name = "name") String name) {
return "say1" +name;
}
}
4 测试类
import javax.xml.ws.Endpoint;
public class StartWebService {
public static void main(String[] args) {
String address = "http://localhost:9410/ws";
Endpoint.publish(address, new TestServiceImpl());
System.out.println("启动成功");
}
}
5 启动
6 访问 http://localhost:9410/ws?wsdl
7 使用 SoapUI 测试接接口 (相当于postman)
8 百度网盘连接
链接:https://pan.baidu.com/s/1eGJKdnFUlHY2FoQaYL_XuA?pwd=1234
提取码:1234提取码:1234