from client import request
import sys,json
base=sys.argv[1];rows=[]
for mandatory in ['0','1']:
actual=request(base,header={'mustUnderstand':mandatory})
if mandatory=='0':assert actual['status']==200 and actual['return_value']=='6'
else:assert actual['fault_local']=='MustUnderstand'
rows.append(actual)
other=request(base,header={'mustUnderstand':'1','actor':'urn:mbsky:other-node'});assert other['status']==200 and other['return_value']=='6';rows.append(other)
for mandatory in ['false','0','true','1']:
actual=request(base,version='1.2',header={'mustUnderstand':mandatory})
if mandatory in {'false','0'}:assert actual['return_value']=='6' and actual['fault_code'] is None
else:assert actual['fault_local']=='MustUnderstand'
rows.append(actual)
other12=request(base,version='1.2',header={'mustUnderstand':'true','role':'http://www.w3.org/2003/05/soap-envelope/role/none'});assert other12['return_value']=='6' and other12['fault_code'] is None;rows.append(other12)
print(json.dumps(rows,ensure_ascii=False))
本例需在 PHP 8.4.27 SOAP;Python 3.12 lxml;仅回环HTTP 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:PHP 8.4.27 SOAP;Python 3.12 lxml;仅回环HTTP
入口文件:projects/soap-protocol-lab/header.py
预期结果与验证条件观察提示
- 本章固定业务、版本或Fault分支逐项与实际响应对应
- 结果值按应用return字段读取,元数据单独保留
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联10章) · 含当前章节或实例 · mbskycom202611a443.zip