XML
1.XML格式:传输数据,存储数据
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
2.XML命名空间
xmlns命名空间:(防止冲突的)
防止不同文档中因为标签名字相同而发生命名冲突,但是许多公司会将命名空间写成一些有意义的东西:将命名空间当做指针来使用 例如spring aop扫描,会将命名空间当做一个地址来扫描
<root>
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table xmlns:f="http://www.w3cschool.cc/furniture">
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>
3.DTD文件的主要功能是验证你编写的代码的合法性,是否符合xml规范,当然还有代码提示的功能
SOAP通信协议
1.SOAP是一种简单地基于xml的通信协议,是一种消息格式,它使应用程序在http上进行信息交换或者说SOAP是用于访问网络服务的协议
2.
SOAP的元素,类似于HTML的元素,
envelope:标识此xml文档为soap
header
body:所有的调用和响应信息
fault:处理此消息所发生的错误的信息
消息的基本结构:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
...
</soap:Header>
<soap:Body>
...
<soap:Fault>
...
</soap:Fault>
</soap:Body>
</soap:Envelope>
3.http在tcp/ip之上进行通信,
http客户机使用tcp连接到http服务器,建立连接后,客户机向服务器发送http请求消息
请求
POST /item HTTP/1.1
Host: 189.123.255.239
Content-Type: text/plain Content-Type:内容类型
Content-Length: 200 Content-Type:请求或者响应主体的字节数
响应
200 OK
Content-Type: text/plain
Content-Length: 200
4.soap=xml+http+rpc可以绕过防火墙 而rpc不可以rpc常伴有兼容性和安全性问题
WSDL(web service description language)
网络描述服务语言,是一个用xml定义的文档
<portType> web service 执行的操作
<message> web service 使用的消息
<types> web service 使用的数据类型
<binding> web service 使用的通信协议
示例文档结构
<definitions>
<types>
data type definitions........
</types>
<message>
definition of the data being communicated....
</message>
<portType>
set of operations......
</portType>
<binding>
protocol and data format specification....
</binding>
</definitions>
WSDL 端口
元素是最重要的 WSDL 元素。
它可描述一个 web service、可被执行的操作,以及相关的消息。
可以把 元素比作传统编程语言中的一个函数库(或一个模块、或一个类)。
WSDL 消息
元素定义一个操作的数据元素。
每个消息均由一个或多个部件组成。可以把这些部件比作传统编程语言中一个函数调用的参数。
WSDL types
元素定义 web service 使用的数据类型。
为了最大程度的平台中立性,WSDL 使用 XML Schema 语法来定义数据类型。
WSDL Bindings
元素为每个端口定义消息格式和协议细节。