webservice也可以叫xml web service webervice,轻量级的独立的通讯技术
1、基于web服务,服务端提供的服务接口让客户端访问
2、跨平台、跨语言的整合方案。
webservice中的一些概念
WSDL(网络服务描述语言,Web Services Description Language):
是一门基于 XML 的语言,用于描述 Web Services 以及如何对它们进行访问。
SOAP(Simple Object Access Protocol简单对象访问协议):
http+xml:webservice通过http协议发送和接受请求的,发送的内容(请求报文)和接收的内容(响应报文)都是采用xml格式进行封装这些特定的HTTP和XML内容格式就是SOAP协议。
SEI(webservice endpoint interface webservice的终端接口):
webservice服务的用来处理请求的接口,也就是发布出去的接口。
例子:
@WebService//SEI
public interface ISayHello {
@WebMethod//SEI中的方法
String sayHello(String name);
}
@WebService
public class SayHelloImpl implements ISayHello {
@Override
public String sayHello(String name) {
System.out.println("call sayHello()");
return "Hello:"+name+",I am Service";
}
}
@SpringBootApplication
public class WebserviceApplication {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8888/pang/hello",new SayHelloImpl());
System.out.println("publish sucess");
SpringApplication.run(WebserviceApplication.class, args);
}
}
启动后:在浏览器输入:http://localhost:8888/pang/hello?wsdl 就可以看到WSDL文档了
<portType> | web service 执行的操作 |
<message> | web service 使用的消息 |
<types> | web service 使用的数据类型 |
<binding> | web service 使用的通信协议 |
WSDL文档关系图:
可以通过SOAPUI调用试试:
实现原理: