蓝色天空网mbsky.com · 知识 · 实践 · 创造W3C · 本地阅读预览
教程 / 计算机基础 / W3C

W3C与 SOAP:消息模型、绑定和历史部件

保留1.1 Note与1.2各部分,区分协议、传输和资料性Primer。

本站独立整理的内容草稿。实例显示的是预期结果;浏览器、服务端运行与技术内容验收尚待完成,本页只用于阅读和图文核对。

学完这一章,你能够

SOAP消息与绑定

SOAP是基于XML的消息框架,HTTP是常用绑定而非唯一可能传输;也不要求所有Web服务都使用SOAP。SOAP1.2不宜再把其名称扩展当作功能边界。

1.1和1.2的阶段

SOAP1.1在2000年作为Note提交,发布不是W3C对其所有内容的认可。SOAP1.2已经有2003及2007第二版,不能再说工作组“正在制定”而不给历史时间。

全部部件和扩展

Primer、Messaging Framework、Adjuncts、Test Collection各自初版/第二版,Attachments、Email Binding、Normalization、Serialization/MTOM及WS-Addressing Core/SOAP Binding全部保留。文档的规范性和推荐轨道应按官方元数据逐项区分,不能统一标Recommendation。

本例核对Envelope/Body/Fault与命名空间/错误结构,HTTP响应还需实际服务另验;解析出XML不代表所有Header mustUnderstand、附件、可靠投递或认证已实现。

历史规范逐项时间线(日期和阶段对应指定历史版本)

规范条目官方版本名日期当时阶段指定版本地址
SOAP 1.2 PrimerSOAP Version 1.2 Part 0: Primer2003-06-24Recommendationhttps://www.w3.org/TR/2003/REC-soap12-part0-20030624/
SOAP 1.2 Primer (2.Ed)SOAP Version 1.2 Part 0: Primer (Second Edition)2007-04-27Recommendationhttps://www.w3.org/TR/2007/REC-soap12-part0-20070427/
SOAP 1.2 MessagingSOAP Version 1.2 Part 1: Messaging Framework2003-06-24Recommendationhttps://www.w3.org/TR/2003/REC-soap12-part1-20030624/
SOAP 1.2 Messaging (2.Ed)SOAP Version 1.2 Part 1: Messaging Framework (Second Edition)2007-04-27Recommendationhttps://www.w3.org/TR/2007/REC-soap12-part1-20070427/
SOAP 1.2 AdjunctsSOAP Version 1.2 Part 2: Adjuncts2003-06-24Recommendationhttps://www.w3.org/TR/2003/REC-soap12-part2-20030624/
SOAP 1.2 Adjuncts (2.Ed)SOAP Version 1.2 Part 2: Adjuncts (Second Edition)2007-04-27Recommendationhttps://www.w3.org/TR/2007/REC-soap12-part2-20070427/
SOAP 1.2 Test CollectionSOAP Version 1.2 Specification Assertions and Test Collection2003-06-24Recommendationhttps://www.w3.org/TR/2003/REC-soap12-testcollection-20030624/
SOAP 1.2 Test Collection (2.Ed)SOAP Version 1.2 Specification Assertions and Test Collection (Second Edition)2007-04-27Recommendationhttps://www.w3.org/TR/2007/REC-soap12-testcollection-20070427/
SOAP 1.2 AttachmentsSOAP 1.2 Attachment Feature2004-06-08Notehttps://www.w3.org/TR/2004/NOTE-soap12-af-20040608/
SOAP 1.2 Email BindingsSOAP Version 1.2 Email Binding2002-07-03Notehttps://www.w3.org/TR/2002/NOTE-soap12-email-20020703
SOAP 1.2 NormalizationSOAP Version 1.2 Message Normalization2003-10-08Notehttps://www.w3.org/TR/2003/NOTE-soap12-n11n-20031008/
SOAP 1.2 SerializationSOAP Message Transmission Optimization Mechanism2004-06-08Last Call Working Drafthttps://www.w3.org/TR/2004/WD-soap12-mtom-20040608/
Web Services Addressing 1.0 - CoreWeb Services Addressing 1.0 - Core2006-05-09Recommendationhttps://www.w3.org/TR/2006/REC-ws-addr-core-20060509/
Web Services Addressing 1.0 - SOAPWeb Services Addressing 1.0 - SOAP Binding2006-05-09Recommendationhttps://www.w3.org/TR/2006/REC-ws-addr-soap-20060509/

概念、用途与有效条件

术语/形式含义及用途边界
Envelope/Body消息包络与正文1.1/1.2命名空间不同
Fault结构化错误消息不是任意HTTP失败都叫SOAPFault
Primer入门说明REC出版物也可含说明性内容
绑定可对应HTTP等传输SOAP不只能HTTP
本地解析检验本包消息结构未联系外部SOAP服务

本章独立核心源码与验证步骤

python · 阅读源码
from mbsky_lab import *
def run():
 ns='http://www.w3.org/2003/05/soap-envelope';envelope=etree.Element('{'+ns+'}Envelope',nsmap={'env':ns});body=etree.SubElement(envelope,'{'+ns+'}Body');payload=etree.SubElement(body,'{urn:mbsky:service}Result');payload.text='mbsky.com'
 parsed=etree.fromstring(etree.tostring(envelope),xml_parser());assert parsed.find('{'+ns+'}Body/{urn:mbsky:service}Result').text=='mbsky.com'
 fault=etree.fromstring(('<env:Envelope xmlns:env="'+ns+'"><env:Body><env:Fault><env:Code><env:Value>env:Sender</env:Value></env:Code><env:Reason><env:Text xml:lang="en">Invalid learning input</env:Text></env:Reason></env:Fault></env:Body></env:Envelope>').encode(),xml_parser());assert fault.xpath('string(//env:Fault/env:Code/env:Value)',namespaces={'env':ns})=='env:Sender'
 rows=standards('w3c-soap');primer=next(r for r in rows if r['label']=='SOAP 1.2 Primer (2.Ed)');assert primer['status']=='Recommendation'and primer['api_informative_flag']is True
 return {'actual_SOAP12_namespace':ns,'body_result':'mbsky.com','fault_code':'env:Sender','recommendation_can_contain_informative_material':True,'historical_rows':len(rows),'no_HTTP_binding_or_remote_service_claim':True}
if __name__=='__main__':emit('w3c-soap',run)
W3C与 SOAP:消息模型、绑定和历史部件:独立验证

所需环境:Windows / Python3.12 / lxml6.1.3 / SaxonC12.9.0 / RDFLib7.1.4;浏览器Edge156

当前源码 SHA256:3343fbe3b9cd64f90abc5f9f057b4959ebd28a4cb588e96f1f83560414403664

下载本站示例源码
预期结果 · 待实际运行核验
  • SOAP1.2包络、正文和Fault按命名空间检查;没有发远程请求。

常见错误与边界

  • 将历史文档日期/阶段当作现行状态,或把REC所有段落误当规范性要求。
  • 用元数据/解析/局部运行代替整份规范语义验收及完整互操作性。

练习与解答

只改一个合法输入,先写预期,再观察对应程序或界面;注明未验证的设备与版本。

展开参考解答

对照指定版本、处理器、命名空间及失败条件,保持运行输入/输出/源码校验值对应。

规范与官方依据