Beispiel #1
0
def _write_wsdl(config):
    from lxml import etree

    from spyne.interface.wsdl import Wsdl11
    from spyne.test.sort_wsdl import sort_wsdl
    from spyne.util.appreg import applications

    for (tns, name), appdata in applications.items():
        appdata.app.transport = "no_transport_at_all"
        wsdl = Wsdl11(appdata.app.interface)
        wsdl.build_interface_document('hxxp://invalid_url')
        doc = wsdl.get_interface_document()
        elt = etree.parse(StringIO(doc))
        sort_wsdl(elt)

        file_name = join(config.write_wsdl, 'wsdl.%s.xml' % name)

        try:
            os.makedirs(dirname(file_name))
        except OSError:
            pass

        try:
            with open(file_name, 'w') as f:
                f.write(etree.tostring(elt, pretty_print=True))
        except Exception as e:
            print("Error:", e)
            return -1

        print(file_name, "written.")

    return True  # to force exit
Beispiel #2
0
def output_wsdl(app):
    app.transport = "no_transport_at_all"

    wsdl = Wsdl11(app.interface)

    wsdl.build_interface_document('http://localhost:5000/soap')
    doc = wsdl.get_interface_document()

    tree = etree.parse(BytesIO(doc))
    sort_wsdl(tree)

    file_name = 'wsdl.%s.xml' % "spyneapp"

    with open(file_name, 'wb') as f:
        f.write(etree.tostring(tree, pretty_print=True))
Beispiel #3
0
#!/usr/bin/env python

from lxml import etree
from spyne.test.sort_wsdl import sort_wsdl
from spyne.interface.wsdl import Wsdl11

from spyne.test.interop.server._service import services
from spyne.application import Application

app = Application(services, 'spyne.test.interop.server')
app.transport = 'http://schemas.xmlsoap.org/soap/http'
wsdl = Wsdl11(app.interface)
wsdl.build_interface_document('http://localhost:9754/')
elt = etree.ElementTree(etree.fromstring(wsdl.get_interface_document()))
sort_wsdl(elt)
s = etree.tostring(elt)

# minidom's serialization seems to put attributes in alphabetic order.
# this is exactly what we want here.
from xml.dom.minidom import parseString
doc = parseString(s)
s = doc.toprettyxml(indent='  ', newl='\n', encoding='utf8')
s = s.replace(" xmlns:","\n                  xmlns:")

open('wsdl.xml', 'w').write(s)
print 'wsdl.xml written'