蓝色天空.知识 · 实践 · 创造
我的收藏
在线代码实验室

WSDL 语法参考:完整结构与草案迁移:核心实例

PYTHONPython 3.12 lxml;PHP 8.4.27 SOAP;回环HTTPinspect_syntax.py
inspect_syntax.py17 行
from pathlib import Path
from lxml import etree
B=Path(__file__).resolve().parent
root=etree.parse(str(B/'public/service.wsdl'),etree.XMLParser(resolve_entities=False,no_network=True)).getroot()
W='http://schemas.xmlsoap.org/wsdl/';X='http://www.w3.org/2001/XMLSchema'
messages={e.get('name') for e in root.findall('{'+W+'}message')};ports={e.get('name') for e in root.findall('{'+W+'}portType')};bindings={e.get('name') for e in root.findall('{'+W+'}binding')}
schema=root.find('{'+W+'}types/{'+X+'}schema');elements={e.get('name') for e in schema.findall('{'+X+'}element')}
def reference(e,attribute,names):
 value=e.get(attribute);prefix,local=value.split(':',1);assert e.nsmap[prefix]=='urn:mbsky:site';assert local in names,(attribute,value)
for e in root.findall('.//{'+W+'}input')+root.findall('.//{'+W+'}output'):
 if e.get('message'):reference(e,'message',messages)
for e in root.findall('{'+W+'}binding'):reference(e,'type',ports)
for e in root.findall('.//{'+W+'}port'):reference(e,'binding',bindings)
for e in root.findall('.//{'+W+'}part'):reference(e,'element',elements)
assert not root.findall('{'+W+'}serviceType')
print({'message_references_resolved':True,'type_references_resolved':True,'historical_serviceType_not_inserted':True,'scope':'owned teaching rules, not a full WSDL validator'})
本例需在 Python 3.12 lxml;PHP 8.4.27 SOAP;回环HTTP 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程

运行环境:Python 3.12 lxml;PHP 8.4.27 SOAP;回环HTTP

入口文件:projects/wsdl-lab/inspect_syntax.py

预期结果与验证条件观察提示
  • 本章固定结构、引用或目录查找断言成立
  • 声明为抽象或本地目录的内容不冒充协议实现

请结合实际环境逐项观察。

附件与关联工程包下载

下载课程关联工程包:WSDL

课程关联工程包(登记关联8章) · 含当前章节或实例 · mbskycom202611a537.zip
SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习