I've got a working Spyne/SOAP/WSDL server - how can I save the schema that it is generated? I want to be able to compare the generated schema against an existing schema but it looks from the logs like a schema is generated as a temporary document and then deleted.
2 回答
1
我刚刚将这个功能添加到神经元中。
这是一个更清洁的版本:
from lxml import etree
from spyne.interface.wsdl import Wsdl11
from spyne.test.sort_wsdl import sort_wsdl
app = Application(...) # a spyne.Application instance
# Hack to make WSDL generator happy
app.transport = "no_transport_at_all"
wsdl = Wsdl11(app.interface)
# A real URL can be passed here, if it's known in advance
wsdl.build_interface_document('hxxp://invalid_url')
doc = wsdl.get_interface_document()
# We need to do it via StringIO because sort_wsdl expects
# an ElementTree instance
tree = etree.parse(StringIO(doc))
sort_wsdl(tree)
file_name = 'wsdl.%s.xml' % name
with open(file_name, 'w') as f:
f.write(etree.tostring(elt, pretty_print=True))
如果您只需要 Xml Schema 文档,请改用 XmlSchema 类:
from spyne.interface.xml_schema import XmlSchema
app = Application(...) # a spyne.Application instance
document = XmlSchema(app.interface)
document.build_interface_document()
schemas = document.get_interface_document()
并且您有一个命名空间的字典:模式中的 schema_doc 对。
于 2015-07-14T09:50:42.167 回答
0
有一个 hacky 方法可以做到这一点,即在 Spyne 库中找到使用后删除模式的代码并注释掉删除。然后,您可以获取架构(日志记录有助于指示它的位置),然后重新启用库代码。但是,如果有一些标志或控件生成一个模式并且至少说“不要删除它,在这里给我保存一份副本......”,那就更好了。
于 2015-07-14T07:52:05.770 回答