Reputation: 1
I have developed a web service, using spyne.protocol.soap.soap11
when running In Django command (python manage runserver), it works as expected:
1.I can get wsdl file from $url?wsdl
2.call a web service and get response
but when deployed in apache server, it response $url?wsdl with status 200 OK but no content:
Connection →close
Content-Length →0
Content-Type →text/xml; charset=utf-8
Date →Mon, 16 Oct 2017 02:22:08 GMT
Server →Apache/2.2.15 (CentOS)
and I can also call a web service, and the server does what I want(insert a data to the database) but apache server response no content.
Note: All above running on the same machine, same python
I have searched in google and StackOverflow, but there are no similar questions.
1 class AbnormalService(ServiceBase):
2 @rpc(Unicode, Unicode, Integer, Integer, Integer, _returns=Unicode)
3 def abnormal(ctx, username, password, locationID, abnormalID, smallAbnormalID):
4 try:
5 AbnormalRecord.objects.create(location_id=locationID, abnormal_id=abnormalID, smallAbnormal_id=smallAbnormalID)
6 except Exception as ex:
7 return str(ex)
8 return "OK"
This is my spyne web service view. And line 5 did excuted on apache server(Database added a line). And It is supposed to responding like:
<?xml version='1.0' encoding='UTF-8'?>
<soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="spyne.examples.django">
<soap11env:Body>
<tns:abnormalResponse>
<tns:abnormalResult>OK</tns:abnormalResult>
</tns:abnormalResponse>
</soap11env:Body>
</soap11env:Envelope>
But the respons with header Content-Length:0, and web service did excuted
I had try add WSGIApplicationGroup %{GLOBAL} to httpd.conf, nothing changed.
My django setting:
urls:
url(r'^uploadrecords', DjangoView.as_view(
services=[views.AbnormalService], tns='spyne.examples.django',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11(),
cache_wsdl=False)),
url(r'^api/', DjangoView.as_view(application=views.app)),`<br>
views:
class AbnormalService(ServiceBase):
@rpc(Unicode, Unicode, Integer, Integer, Integer, _returns=Unicode)
def abnormal(ctx, username, password, locationID, abnormalID, smallAbnormalID):
try:
AbnormalRecord.objects.create(location_id=locationID, abnormal_id=abnormalID, smallAbnormal_id=smallAbnormalID)
except Exception as ex:
return str(ex)
return "OK"
app = Application([AbnormalService],
'spyne.examples.django',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11(validator='lxml'),
)
abnormal_service = csrf_exempt(DjangoApplication(app))
settings:
WSGIApplicationGroup %{GLOBAL}
WSGIPythonPath /var/www/html/kanban
Listen 9000
<VirtualHost *:9000>
<Directory "/var/www/html/kanban/kanban">
<Files wsgi.py>
Order allow,deny
Allow from all
</Files>
WSGIApplicationGroup %{GLOBAL}
</Directory>
WSGIScriptAlias / /var/www/html/kanban/kanban/wsgi.py
WSGIApplicationGroup %{GLOBAL}
ServerName dummy-host.example.com
ErrorLog logs/django_log
CustomLog logs/django_custom_log common
</VirtualHost>
Upvotes: 0
Views: 468