标签:article 一个 end ISE 窗口 ebs string pre turn
1,定义一个接口
public interface HaiService {
//定义一个方法
String speak(String str);
}
2,编写一个实现类
import javax.jws.WebService;
import com.lxinet.jeesns.test.ws.HaiService;
//这里要用WebService 注解
@WebService
public class HaiServiceImpl implements HaiService {
@Override
public String speak(String str) {
System.out.println("来到服务端了。。。。。"+str);
return "hai pong";
}
}
3,发布服务
import javax.xml.ws.Endpoint;
import com.lxinet.jeesns.test.ws.HaiService;
import com.lxinet.jeesns.test.ws.impl.HaiServiceImpl;
public class ClientTest {
public static void main(String[] args) {
HaiService ws=new HaiServiceImpl();
Endpoint.publish("http://192.168.43.119:8083/ws", ws);
System.out.println("服务发布成功。。。");
}
}
4,通过浏览器访问
http://192.168.43.119:8083/ws?wsdl
5,通过代码访问
在dos窗口 输入 :wsimport -s D:\html http://192.168.43.119:8083/ws?wsdl
将代码保存到本地,然后将代码拷贝到一个java工程中
编写一个客户端类
public class ClientTest {
public static void main(String[] args) {
HaiServiceImplService service=new HaiServiceImplService();
HaiServiceImpl impl = service.getHaiServiceImplPort();
String speak = impl.speak("hui");
System.out.println("client res:"+speak);
}
}
6,通过soapui访问
参考:https://blog.csdn.net/weiqing723/article/details/78865734
标签:article 一个 end ISE 窗口 ebs string pre turn
原文地址:https://www.cnblogs.com/dongma/p/9980192.html