I recently set up a Spyne application for sending an XML response. As it stands now, the application is correctly sending the response -- however, it is currently sending a UTF-8 encoded document. I would like to instead send the document as Latin-1 (iso-8859-1) encoded.
I've tried to use the "encoding=" argument, but it seems to have no effect on the response beyond changing the header.
Below is the code for my application:
import logging
from spyne import Application, rpc, ServiceBase, Integer, Unicode, AnyDict
from spyne import Iterable
from spyne.protocol.soap import Soap11
from spyne.protocol.xml import XmlDocument
from spyne.server.wsgi import WsgiApplication
class CoreService(ServiceBase):
@rpc(Unicode, Unicode, Integer, Integer, _returns=AnyDict) #@rpc arguments corespond to the retrieve_score() arguments below
def retreive_score(ctx):
return score # This is a dictionary
application = Application([CoreService], 'spyne.iefp.soap',
in_protocol=Soap11(validator='lxml'),
out_protocol=XmlDocument(polymorphic=True, encoding='iso-8859-1'))
wsgi_application = WsgiApplication(application)
if __name__ == '__main__':
import logging
from wsgiref.simple_server import make_server
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)
logging.info("listening on port 8000")
logging.info("wsdl is at: http://10.10.28.84:8000/?wsdl")
server = make_server('0.0.0.0', 8000, wsgi_application)
server.serve_forever()