在一些教程之后,我正在尝试使用 Django 制作一个小的“Hello World”网络服务,但我一遍又一遍地遇到同样的障碍。我已经定义了 view.py 和 soaplib_handler.py:
视图.py:
from soaplib_handler import DjangoSoapApp, soapmethod, soap_types
class HelloWorldService(DjangoSoapApp):
__tns__ = 'http://saers.dk/soap/'
@soapmethod(_returns=soap_types.Array(soap_types.String))
def hello(self):
return "Hello World"
肥皂库处理程序.py:
from soaplib.wsgi_soap import SimpleWSGISoapApp
from soaplib.service import soapmethod
from soaplib.serializers import primitive as soap_types
from django.http import HttpResponse
class DjangoSoapApp(SimpleWSGISoapApp):
def __call__(self, request):
django_response = HttpResponse()
def start_response(status, headers):
status, reason = status.split(' ', 1)
django_response.status_code = int(status)
for header, value in headers:
django_response[header] = value
response = super(SimpleWSGISoapApp, self).__call__(request.META, start_response)
django_response.content = "\n".join(response)
return django_response
似乎“响应=超级......”行给我带来了麻烦。当我加载映射在 url.py 中的 /hello_world/services.wsdl 时,我得到:
/hello_world/service.wsdl 'module' 对象的 AttributeError 没有属性 'tostring'
有关完整的错误消息,请参见此处: http ://saers.dk:8000/hello_world/service.wsdl
您对我为什么会收到此错误有任何建议吗?ElementTree 在哪里定义?