Skip to content

Instantly share code, notes, and snippets.

@plq
Created July 13, 2012 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plq/3104432 to your computer and use it in GitHub Desktop.
Save plq/3104432 to your computer and use it in GitHub Desktop.
jussi_test
#!/usr/bin/env python
from suds.client import Client
client = Client("http://localhost:9753/?wsdl")
print client.service.TestService("x")
#!/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 XmlAttribute
from spyne.model.complex import Array
from spyne.model.primitive import String
from spyne.model.primitive import Double
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
###############################################################################
# TestResponse
###############################################################################
class MyComplexModel(ComplexModelBase):
__namespace__ = 'http://xml.test.org/TestResponse/2012/07/13'
__metaclass__ = ComplexModelMeta
class InvalidValue(MyComplexModel):
Attr = String
Value = Double
class FailedValidation(MyComplexModel):
id = XmlAttribute(String)
InvalidValues = Array(InvalidValue.customize(min_occurs=1))
Rule = String
class TestResponse(MyComplexModel):
TaskId = XmlAttribute(String)
FailedValidation = FailedValidation.customize(max_occurs='unbounded')
###############################################################################
# Service classes
###############################################################################
class TestService(ServiceBase):
@rpc(String, _returns=TestResponse)
def TestService(ctx, data):
iv1 = InvalidValue(Attr='Basal area', Value=100.)
ivs1 = [iv1]
f1 = FailedValidation(id='10', Rule='Some validation rule',
InvalidValues=ivs1)
iv2 = InvalidValue(Attr='Basal area', Value=100.)
ivs2 = [iv2]
f2 = FailedValidation(id='11', Rule='Some other validation rule',
InvalidValues=ivs2)
fv = [f1, f2]
res = TestResponse(TaskId='1', FailedValidation=fv)
return res
application = Application([TestService],
'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