【发布时间】:2019-08-21 16:20:04
【问题描述】:
我最近设置了一个用于发送 XML 响应的 Spyne 应用程序。就目前而言,应用程序正在正确地发送响应——但是,它当前正在发送一个 UTF-8 编码的文档。我想将文档作为 Latin-1 (iso-8859-1) 编码发送。
我尝试使用“encoding=”参数,但除了更改标头之外,它似乎对响应没有任何影响。
以下是我的应用程序的代码:
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()
【问题讨论】: