Last active
August 29, 2015 14:00
-
-
Save plq/11384113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf8 | |
# Requires Spyne 2.11 | |
from spyne.model.primitive import * | |
from spyne.model.complex import * | |
from spyne.application import Application | |
from spyne.protocol.soap import Soap11 | |
from spyne.server.wsgi import WsgiApplication | |
from spyne.decorator import rpc | |
from spyne.service import ServiceBase | |
NS = 'urn:...' | |
class Attr(ComplexModel): | |
__namespace__ = NS | |
_type_info = [ | |
('ID', XmlAttribute(UnsignedInteger32)), | |
] | |
class ModifyRequest(ComplexModel): | |
__namespace__ = NS | |
_type_info = [ | |
('returnData', XmlAttribute(Unicode(values=['everything', 'something', 'anything', 'etc']))), | |
('attr', Attr), | |
('data', AnyXml), | |
] | |
class SomeService(ServiceBase): | |
@rpc(ModifyRequest, _body_style='bare') | |
def modifyRequest(ctx, request): | |
pass | |
if __name__=='__main__': | |
from wsgiref.simple_server import make_server | |
logging.basicConfig(level=logging.DEBUG) | |
logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG) | |
logging.info("listening to http://127.0.0.1:8000") | |
logging.info("wsdl is at: http://localhost:8000/?wsdl") | |
application = Application([SomeService], NS, | |
in_protocol=Soap11(validator='lxml'), | |
out_protocol=Soap11() | |
) | |
wsgi_application = WsgiApplication(application) | |
server = make_server('127.0.0.1', 8000, wsgi_application) | |
server.serve_forever() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment