APACHE2 Premature end of script headers: handler.py

Asked by User

Hello, i'm using Ubuntu 12.04 i want make a SOAP web service, this is what i've done:

PYTHON3 INSTALL

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:fkrull/deadsnakes
$ sudo apt-get update
$ sudo apt-get install python3.3

DISTRIBUTE-0.7.3 INSTALL

$ cd /home/user/distribute-0.7.3
$ sudo python3.3 setup.py install

JURKO-SUDS-A8C49059DA72 INSTALL

$ cd /home/user/jurko-suds-a8c49059da72
$ sudo python3.3 setup.py install

LADON-0.8.9 INSTALL

$ cd /home/user/ladon-0.8.9
$ sudo python3.3 setup.py install

THIS IS THE SOAP CLIENT

#!/usr/bin/python3.3
# -*- coding: UTF-8 -*-

from suds.client import Client

try:
    # client = Client("http://ladonize.org/python-demos/Calculator/soap/description") --> with this line it runs OK
    # client = Client("http://localhost:8080/Calculator/soap/description") --> with Ladon-ctl this works fine!
       client = Client("http://localhost/ws/Calculator/soap/description")

    # Calculate 34+56
    result = client.service.add(34, 56)
    print("Content-Type: text/html;charset=utf-8\n")
    print(result)
except Exception as e:
    print("Content-Type: text/html;charset=utf-8\n")
    print(e)

THIS IS THE SOAP SERVER (ecows.py)

#!/usr/bin/python3.3

from ladon.ladonizer import ladonize

class Calculator(object):
    """
    Questo servizio esegue la somma algebrica di due interi.
    """
    @ladonize(int, int, rtype=int)
    def add(self, a, b):
        """
        Somma il valore di due interi e restituisce il valore risultante sotto forma di intero

        @param a: 1° intero
        @param b: 2° intero
        @rtype: Risultato dell'addizione'
        """
        return a + b

If i test everything with "ladon-ctl testserve /var/www/ws/ecows.py -p 8080" (ladon2.7ctl OR ladon3.3ctl seems to be not a valid command)
Everything runs ok!
The problem is with apache2

This is my configuration:

<VirtualHost *:80>
 ServerAdmin webmaster@localhost

 DocumentRoot /var/www
 WSGIScriptAlias /ws/ /var/www/ws/handler.py
 <Directory />
  Options Indexes FollowSymLinks Includes ExecCGI
  #Options FollowSymLinks
  AllowOverride None
 </Directory>
 <Directory /var/www/>
  Options Indexes FollowSymLinks Includes ExecCGI
  #Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
  AddHandler cgi-script .py
  AddHandler default-handler .html .htm
 </Directory>

 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 <Directory "/usr/lib/cgi-bin">
  AllowOverride None
  Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  Order allow,deny
  Allow from all
 </Directory>

 ErrorLog ${APACHE_LOG_DIR}/error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

And this is my handler.py

#!/usr/bin/env python3.3

from ladon.server.wsgi import LadonWSGIApplication
from os.path import abspath, dirname

application = LadonWSGIApplication(
    ['ecows'], [dirname(abspath('/var/www/ws/ecows.py'))],
    catalog_name='ECOWS webservice catalog',
    catalog_desc='Funzioni disponibili')

So i have restartted my apache webserver and if i try

"http://localhost/ws"
There is a 500 Internal server error and the apache log says only "Premature end of script headers: handler.py"

With ladon-ctl and http://localhost:8080/ EVERYTHING WORKS FINE!!!

What am i doing wrong???
Tank you very much!!

Question information

Language:
English Edit question
Status:
Solved
For:
ladon Edit question
Assignee:
No assignee Edit question
Solved by:
User
Solved:
Last query:
Last reply:
Revision history for this message
User (xdarkenx) said :
#1

Up

Revision history for this message
User (xdarkenx) said :
#2

Tested everything on a celan machine.
The problem is "easy_install3 ladon" it atempts to install "Jinja2 2.7" that is not compatible with "python3.2" and "ladon".

so you must manually install "jinja2 2.6" and ladon and everything works fine.