参考https://blog.youkuaiyun.com/c99463904/article/details/76018436
服务端:
1.编写SEI(Service Endpoint Interface),SEI在webservice中称为portType,在java中就是普通接口
public interface ICameraService {
public void test();
}
2. 编写SEI实现类,此类作为webservice提供服务类
@WebService///@WebService表示该类是一个服务类,需要发布其中的public的方法
@Service("CameraServiceImpl")//Spring mvc 纳入容器管理
public class CameraServiceImpl implements ICameraService {
@Override
public void test() {
System.out.print("asada");
}
}
3.发布服务,Endpoint类发布服务,publish方法,两个参数:1.服务地址;2.服务实现类
import javax.xml.ws.Endpoint;
import com.ctfo.spring.SpringInit;
public class Start {
public static void main(String[] args) {
Endpoint.publish("http://192.168.1.1

本文介绍了如何实现WebService客户端调用服务端接口。服务端包括编写SEI接口和实现类,使用Endpoint类发布服务,并通过查看WSDL文件验证服务发布。客户端则可以通过JDK的wsimport工具,根据WSDL文件生成Java客户端代码,然后像调用本地类一样调用WebService方法。
最低0.47元/天 解锁文章
2022

被折叠的 条评论
为什么被折叠?



