我如何使用 spyne 接受分块编码数据

问题描述

我尝试使用 spyne 的示例 python 文件来接受来自 http 请求的分块正文数据,代码如下:

class HelloWorldService(ServiceBase):
    # @rpc(Unicode,Integer,_returns=Iterable(Unicode))
    @rpc(Unicode,_returns=Unicode)
    def say_hello(self,name,times):
        """for i in range(times):
            yield 'Hello,%s' % name"""
        print(name,times)
        return 'success'


application = Application([HelloWorldService],tns='spyne.examples.hello',in_protocol=Soap11(validator='lxml'),out_protocol=JsonDocument()
                          )
wsgi_app = WsgiApplication(application,chunked=True)

然后抛出这个错误

XMLSyntaxError("Start tag expected,'<' not found,line 1,column 1")

例如,当我发送这样的数据时:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <say_hello xmlns="spyne.examples.hello">
      <name>str1</name>
      <times>1</times>
    </say_hello>
  </soapenv:Body>
</soapenv:Envelope>

错误会是这样的:

XMLSyntaxError("Start tag expected,column 1") in string b'f7\r\n<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><say_hello xmlns="spyne.examples.hello"><name>str1</name><times>1</times></say_hello></soapenv:Body></soapenv:Envel'

似乎spyne服务器已经检查了“f7”的内容长度,但是窃取了其中包含内容长度字符串的数据字符串,导致请求体的最后一个像“ope>”丢失。 不知道是不是有什么问题

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)