Last active
December 14, 2015 05:49
-
-
Save plq/5037952 to your computer and use it in GitHub Desktop.
spyne testcase
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
| import suds | |
| client = suds.client.Client("http://127.0.0.1:8080/?wsdl", cache=None) | |
| result = client.service.test(6000.0) | |
| print result |
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
| INFO:root:Spyne version: '2.9.3' | |
| INFO:root:lxml version: '3.1.0' | |
| INFO:root:Float constraints: lt: Decimal('Infinity') le: Decimal('Infinity') gt: Decimal('-Infinity') ge: Decimal('-Infinity') | |
| INFO:root:Integer constraints: lt: Decimal('Infinity') le: Decimal('Infinity') gt: Decimal('-Infinity') ge: Decimal('-Infinity') | |
| DEBUG:spyne.interface._base:populating '__main__.Test ({Test.Test}Test)' types... | |
| DEBUG:spyne.interface._base: adding class "<class 'spyne.model.complex.test'>" for '{test}test' | |
| DEBUG:spyne.interface._base: adding class "<class 'spyne.model.primitive.Float'>" for '{http://www.w3.org/2001/XMLSchema}float' | |
| DEBUG:spyne.interface._base: adding class "<class 'spyne.model.complex.testResponse'>" for '{test}testResponse' | |
| DEBUG:spyne.interface._base: adding class "<class 'spyne.model.primitive.Integer'>" for '{http://www.w3.org/2001/XMLSchema}integer' | |
| DEBUG:spyne.interface._base:populating '__main__.Test' methods... | |
| DEBUG:spyne.interface._base: adding method 'test' to match '{test}test' tag. | |
| DEBUG:spyne.interface._base:From this point on, you're not supposed to make any changes to the class & method structure of the exposed services. | |
| DEBUG:spyne.interface.xml_schema._base:generating schema for targetNamespace='test', prefix: 'tns' in dir '/tmp/.private/plq/tmpVfnw8x' | |
| DEBUG:spyne.interface.xml_schema._base:writing '/tmp/.private/plq/tmpVfnw8x/tns.xsd' for ns test | |
| DEBUG:spyne.interface.xml_schema._base:building schema... | |
| DEBUG:spyne.interface.xml_schema._base:schema <lxml.etree.XMLSchema object at 0x115a6e0> built, cleaning up... | |
| DEBUG:spyne.interface.xml_schema._base:removed '/tmp/.private/plq/tmpVfnw8x' | |
| DEBUG:spyne.interface.xml_schema._base:generating schema for targetNamespace='test', prefix: 'tns' in dir '/tmp/.private/plq/tmpzIQN4B' | |
| DEBUG:spyne.interface.xml_schema._base:writing '/tmp/.private/plq/tmpzIQN4B/tns.xsd' for ns test | |
| DEBUG:spyne.interface.xml_schema._base:building schema... | |
| DEBUG:spyne.interface.xml_schema._base:schema <lxml.etree.XMLSchema object at 0x115e910> built, cleaning up... | |
| DEBUG:spyne.interface.xml_schema._base:removed '/tmp/.private/plq/tmpzIQN4B' | |
| DEBUG:spyne.util.appreg:Registering <spyne.application.Application object at 0x115d810> as ('test', 'Application') | |
| comet.in.arskom.com.tr - - [26/Feb/2013 14:16:32] "GET /?wsdl HTTP/1.1" 200 2189 | |
| DEBUG:spyne.protocol.xml:[1;32mMethod request string:[0m {test}test | |
| DEBUG:spyne.protocol.xml:<SOAP-ENV:Envelope xmlns:ns0="test" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> | |
| <SOAP-ENV:Header/> | |
| <ns1:Body> | |
| <ns0:test> | |
| <ns0:quota>6000.0</ns0:quota> | |
| </ns0:test> | |
| </ns1:Body> | |
| </SOAP-ENV:Envelope> | |
| DEBUG:spyne.protocol.soap.soap11:[1;31mResponse[0m <?xml version='1.0' encoding='ASCII'?> | |
| <senv:Envelope xmlns:tns="test" xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/"> | |
| <senv:Body> | |
| <tns:testResponse> | |
| <tns:testResult>10</tns:testResult> | |
| </tns:testResponse> | |
| </senv:Body> | |
| </senv:Envelope> | |
| comet.in.arskom.com.tr - - [26/Feb/2013 14:16:32] "POST / HTTP/1.1" 200 237 | |
| listening on: http://127.0.0.1:8080/ | |
| WSDL: http://127.0.0.1:8080/?wsdl | |
| Traceback (most recent call last): | |
| File "server.py", line 53, in <module> | |
| server.serve_forever() | |
| File "/usr/lib64/python2.7/SocketServer.py", line 225, in serve_forever | |
| r, w, e = select.select([self], [], [], poll_interval) | |
| KeyboardInterrupt |
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
| import pkg_resources | |
| import spyne | |
| from spyne.service import ServiceBase | |
| from spyne.decorator import rpc | |
| from spyne.model.primitive import * | |
| from spyne.model.complex import * | |
| class Test(ServiceBase): | |
| @rpc(Float, _returns=Integer) | |
| def test(ctx, quota): | |
| return 10 | |
| if __name__ == "__main__": | |
| from spyne.protocol.soap import Soap11 | |
| from spyne.application import Application | |
| from spyne.server.wsgi import WsgiApplication | |
| from wsgiref.simple_server import make_server | |
| logging.basicConfig(level=logging.DEBUG) | |
| logging.getLogger("spyne.protocol.xml").setLevel(logging.DEBUG) | |
| logging.info('Spyne version: %r' % spyne.__version__) | |
| logging.info('lxml version: %r' % pkg_resources.get_distribution("lxml").version) | |
| logging.info('Float constraints: lt: %r le: %r gt: %r ge: %r' % ( | |
| Float.Attributes.lt, | |
| Float.Attributes.le, | |
| Float.Attributes.gt, | |
| Float.Attributes.ge, | |
| )) | |
| logging.info('Integer constraints: lt: %r le: %r gt: %r ge: %r' % ( | |
| Integer.Attributes.lt, | |
| Integer.Attributes.le, | |
| Integer.Attributes.gt, | |
| Integer.Attributes.ge, | |
| )) | |
| app = Application([Test], "test", in_protocol=Soap11(validator="soft"), out_protocol=Soap11(cleanup_namespaces=True)) | |
| host = "127.0.0.1" | |
| port = 8080 | |
| server = make_server(host, port, WsgiApplication(app)) | |
| print "listening on: http://%s:%s/" % (host, port) | |
| print "WSDL: http://%s:%s/?wsdl" % (host, port) | |
| server.serve_forever() |
azurit
commented
Feb 26, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment