我正在尝试使用PyXB为WSDL生成绑定,并且它在标题中给出了AssertionError异常。
根据PyXB文档,我的理解是,http://www.w3.org/1999/xhtml的包存档包含在PyXB中。然而,似乎有些不对劲。它要么没有被使用,要么内容不正确。
我使用以下命令行尝试生成绑定:
python c:\Python27\Scripts\pyxbgen.py --wsdl-location=http://xx.xxx.xxx.xxx/YYY.asmx?WSDL --module=client --write-for-customization
追溯:
Traceback (most recent call last):
File "c:\Python27\Scripts\pyxbgen.py", line 51, in <module> generator.resolveExternalSchema()
File "c:\Python27\lib\site-packages\pyxb\binding\generate.py", line 2647, in resolveExternalSchema
schema = converter(self, sl)
File "c:\Python27\Scripts\pyxbgen.py", line 28, in WSDLToSchema
spec = wsdl.definitions.createFromDOM(pyxb.utils.domutils.StringToDOM(xmld,
location_base=wsdl_uri), process_schema=True, generation_uid=generator.generationUID())
File "c:\Python27\lib\site-packages\pyxb\binding\basis.py", line 1767, in createFromDOM
return self._createFromDOM(node, expanded_name, **kw)
File "c:\Python27\lib\site-packages\pyxb\binding\basis.py", line 1791, in _createFromDOM
return element.CreateDOMBinding(node, self.elementForName(expanded_name), **kw)
File "c:\Python27\lib\site-packages\pyxb\binding\basis.py", line 1735, in elementForName
assert 'elementBinding' in elt_en.namespace()._categoryMap(), 'No element bindings in %s' % (elt_en.namespace(),)
AssertionError: No element bindings in http://www.w3.org/1999/xhtml
另外,我将PYXB_ARCHIVE_PATH环境变量设置为:
C:\Python27\Lib\site-packages\pyxb\bundles\common\raw
我不确定这是否是正确的方法。我也尝试过指定--archive-path命令行选项,但我得到了同样的错误。
答案 0 :(得分:0)
可能你需要使用:
--archive-path=${PYXB_ROOT}/pyxb/bundles/common//:+
作为论点。这将首先在公共包中递归搜索可用的命名空间,然后包括任何其他搜索路径。有一个example in the manual与此接近。