[英]Is there any timeout set in Django 1.4?
我在Django 1.4和Soaplib 2.0中遇到了问题。
当我从客户端发送带有一些大参数的请求时,Django引发异常并发送以下类型的电子邮件:“ [Django]错误(外部IP):内部服务器错误:/ uri / to / soap / service ”
Traceback (most recent call last):
File "/path/to/my/project/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 129, in get_response
raise ValueError("The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name))
ValueError: The view myproject/library.soap.wsgi.view didn't return an HttpResponse object.
我使用服务器端http://soaplib.github.io/soaplib/2_0/pages/helloworld.html#declaring-a-soaplib-service上的常规@soap装饰器。
因此,在服务器配置上看起来像这样:
里面urls.py :
from myproject.server.webservice import WebService
application_view = Application([WebService], 'ws', name='ws').as_django_view()
urlpatterns = patterns(
url(r'^soap/.*', csrf_exempt( application_view )),
)
在myproject / server / webservice.py中 :
from soaplib.core.service import DefinitionBase
class WebService(DefinitionBase):
'''
The actual webservice class.
This defines methods exposed to clients.
'''
def __init__(self, environ):
'''
This saves a reference to the request environment on the current instance
'''
self.environ = environ
super(WebService, self).__init__(environ)
@soap(Array(Array(String)), _returns=Integer)
def my_method(self, params):
return self.process(params)
def process(self, params):
#DO SOMETHING HERE
在客户端 :
#cfg is my configuration file
#params is a dictionary
client = SoapClient(
location = cfg.location,
action = cfg.action, # SOAPAction
namespace = cfg.namespace, #"http://example.com/sample.wsdl",
soap_ns= cfg.soap_ns,
trace = cfg.trace,
ns = cfg.ns)
response = client.my_method(params=params)
我试图从客户端发送非常大的词典,但是它不起作用。
我怀疑Django在此过程中设置了超时并关闭了我的连接。 是否有增加超时或其他原因导致的问题?
顺便说一句,我只使用Django。 我没有配置任何Apache或Nginx。
您的process(self, params)
方法不执行任何操作(事实上,由于它在签名后至少需要一行代码,因此实际上它甚至不是有效的python)。 您应该在那里返回一些值,这些值可用于创建有效的肥皂响应。
附带说明一下,我建议不要再使用soaplib。 它由rpclib取代,而rpclib现在又被称为spyne。 另外,还有其他肥皂服务器库可用,它们更多地关注于SOAP部分(例如pysimplesoap,soapfish)。 我发现这很有用,因为SOAP xml与实际实现之间的抽象往往较少。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.