Created
August 28, 2012 13:12
-
-
Save plq/3497846 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| import datetime | |
| from suds.client import Client | |
| client = Client("http://localhost:9753/?wsdl") | |
| data = client.factory.create("{AAA}PhysicalPersonDataRequest") | |
| data.birthDate = datetime.date(1985,12,11) | |
| print client.service.test(data) |
This file contains hidden or 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 | |
| import logging | |
| logging.basicConfig(level=logging.DEBUG) | |
| logger = logging.getLogger('spyne.protocol.xml') | |
| logger.setLevel(logging.DEBUG) | |
| from spyne.server.wsgi import WsgiApplication | |
| from spyne.protocol.soap.soap11 import Soap11 | |
| from spyne.interface.wsdl.wsdl11 import Wsdl11 | |
| from spyne.model.complex import ComplexModel | |
| from spyne.model.complex import Array | |
| from spyne.model.primitive import Unicode | |
| from spyne.model.primitive import Date | |
| from spyne.model.complex import ComplexModelBase | |
| from spyne.model.complex import ComplexModelMeta | |
| from spyne.application import Application | |
| from spyne.service import ServiceBase | |
| from spyne.decorator import rpc | |
| class PhysicalPersonDataRequest(ComplexModel): | |
| __namespace__ = "AAA" | |
| lastName = Unicode(max_len = 30) | |
| firstName = Unicode(max_len = 30) | |
| birthDate = Date | |
| idnp = Unicode(max_len = 13) | |
| icSerial = Unicode(max_len = 5) | |
| icNumber = Unicode(max_len = 15) | |
| class TestService(ServiceBase): | |
| @rpc(PhysicalPersonDataRequest, _returns=PhysicalPersonDataRequest) | |
| def test(ctx, data): | |
| return data | |
| application = Application([TestService], | |
| tns='http://ws.test.org/testws/', | |
| interface=Wsdl11(), | |
| in_protocol=Soap11(), | |
| out_protocol=Soap11(cleanup_namespaces=True)) | |
| from wsgiref.simple_server import make_server | |
| from wsgiref.validate import validator | |
| wsgi_application = WsgiApplication(application) | |
| server = make_server('0.0.0.0', 9753, validator(wsgi_application)) | |
| logger.info('Starting interop server at %s:%s.' % ('0.0.0.0', 9753)) | |
| logger.info('WSDL is at: /?wsdl') | |
| server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment