我一直在使用SUDS和RPCLib为软件解决方案开发SOAP接口,该解决方案接收PDF文档并返回PNG,并且发现了一个非常有趣的问题。
我编写了测试客户端(使用SUDS)和服务器(使用RPCLib),当要上载和返回的文档小于约3.5Mb时,它们成功运行。但是,在上传较大的文档时,我会收到SUDS错误:
Traceback (most recent call last):
File "MyFunc.py", line 90, in <module>
callMyFuncSOAPService(fName, test_id, fNameOut)
File "MyFuncClient.py", line 77, in callMyFuncSOAPService
temp_list = client.service.createInstance(encoded_data, 19, test_id, 20)
File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 602, in invoke
result = self.send(soapenv)
File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 637, in send
reply = transport.send(request)
File "/usr/local/lib/python2.7/dist-packages/suds/transport/https.py", line 64, in send
return HttpTransport.send(self, request)
File "/usr/local/lib/python2.7/dist-packages/suds/transport/http.py", line 77, in send
fp = self.u2open(u2request)
File "/usr/local/lib/python2.7/dist-packages/suds/transport/http.py", line 118, in u2open
return url.open(u2request, timeout=tm)
File "/usr/lib/python2.7/urllib2.py", line 400, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 418, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1177, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 32] Broken pipe>
当返回文档时,服务器完成处理并返回文档,但客户端挂起。
我有一种感觉,这是由于HTTP传输层的限制,但不知道如何解决这个问题。谢谢!
答案 0 :(得分:1)
您可以增加允许的请求长度。
app = WsgiApplication(...)
app.max_content_length = 10 * 0x100000 # 10 MB
Spyne 2.10和2.9.4将在构造函数中包含这些参数,因此您将能够执行此操作:
WsgiApplication(..., max_content_length=10 * 0x100000)
答案 1 :(得分:0)
我找到了一个可能的解决方案。它涉及更新和编辑spyne库[rpclib的后继者]。
在WSGI.py,函数__wsgi_input_to_iterable()中,我注释掉了引发错误的2行:
raise RequestTooLongError()
问题在于我们从length = str(http_env.get('CONTENT_LENGTH',self.max_content_length))中提取了一个似乎不正确的限制。
我将与SPYNE开发人员联系,看看这个bug可能来自哪个