簡體   English   中英

Django 1.4中是否設置了任何超時?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM