Stivlo'st in Asia

Programming and Travel

Browsing Posts published in May, 2006

Farewell party

No comments

Yesterday we’ve made a little farewell party in my home garden. We had bbq and we were about 20 people.

DSCN2471

After having installed PHP5 SOAP support it’s time to try it… I’ve read the article PHP SOAP Extension from Zend.

Calling a method using WSDL is really easy:

<?php
$client = new SoapClient("http//services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl");
print($client->getQuote("ibm"));
?>

But my aim is to build a small SOAP server. The first step is to create the WSDL and a WDSL generator seems helpful. I’ve tried others unsuccessfully. Very interesting is also a Generic SOAP client that lets you try any WSDL based SOAP webservice.

Here is my first test server:

<?php
soapServer();

function soapServer() {
    ini_set("soap.wsdl_cache_enabled", "0"); //disable WSDL cache
    $server = new SoapServer("person.wsdl");
    $server->setClass("Updater");
    $server->handle();
}

class Updater {

    /**
     * Returns data updated after date
     * @param string $date
     * @return object Person[]
     */
    function getPersons($data) {
        $ret = $this->__queryPersons($data, $gruppo);
        //debugObject("contacten: ",$ret);
        return $ret;
    }
...
?>

Well, finally I could try this technology, hope to try it with Java too.

Update: However I later discovered that the generated WSDL is invalid, for that reason I spent the next days fiddling with tomcat and axis to find a way out.

PHP5 and Soap

No comments

Today I’ve to build a simple webservice using PHP, unfortunately my PHP installation has been built without support for it, so it’s time to update my configure line to add soap support:

PHP MODULE

# make distclean
# ./configure –enable-memory-limit \
–disable-url-fopen-wrapper –with-gd –enable-dbase –enable-exif \
–enable-ftp –with-gettext –with-iconv –enable-mbstring \
–with-jpeg-dir=/usr/lib –with-zlib-dir=/usr/lib –with-kerberos \
–with-png-dir=/usr/lib –enable-gd-native-ttf –with-freetype-dir=/usr/lib \
–with-openssl –with-xml –with-dom –disable-cgi –with-mcrypt \
–with-xsl –enable-javascript –with-mcal \
–with-sablot-js –with-readline –with-imap –with-imap-ssl \
–with-mysql=/var/j_mysql/var/mysql –with-mysqli=/var/j_mysql/bin/mysql_config \
–with-config-file-path=/usr/local/conf/php-module \
–disable-cli –with-apxs=/usr/local/bin/apxs –enable-soap
# make
# make install

PHP CLI

# ./configure –enable-memory-limit \
–disable-url-fopen-wrapper –with-gd –enable-dbase –enable-exif \
–enable-ftp –with-gettext –with-iconv –enable-mbstring \
–with-jpeg-dir=/usr/lib –with-zlib-dir=/usr/lib –with-kerberos \
–with-png-dir=/usr/lib –enable-gd-native-ttf –with-freetype-dir=/usr/lib \
–with-openssl –with-xml –with-dom –disable-cgi –with-mcrypt \
–enable-xslt –with-xslt-sablot –enable-javascript –with-mcal \
–with-sablot-js –with-readline –with-imap –with-imap-ssl \
–with-mysql=/var/j_mysql/var/mysql –with-mysqli=/var/j_mysql/bin/mysql_config \
–with-config-file-path=/usr/local/conf/php-cli \
–disable-cgi –enable-soap
# make
# make install

Courier installation

1 comment

It’s already nearly midnight but I’ve to go on with the server installation. Now it’s courier time, to grant POP/IMAP access to mailboxes. I download it from:

http://www.courier-mta.org/

The latest version for courier-authlib is 0.58 (08-Dec-2005) and the latest for Courier-IMAP is 4.1.0 (25-Feb-2006)

$ tar xfvj courier-authlib-0.58.tar.bz2
$ cd courier-authlib-0.58
$ ./configure –with-mysql-libs=/var/j_mysql/var/mysql/lib/mysql/ \
–with-mysql-includes=/var/j_mysql/var/mysql/include/mysql/ \
–with-authmysql –with-authmysql=yes
$ make
# make install
# make install-configure

$ tar xfvj courier-0.53.2.tar.bz2
$ cd courier-0.53.2
$ ./configure –without-ipv6 –enable-unicode –without-fam –prefix=/usr/lib/courier/
$ make
$ make check
# make install

Now courier is installed, tomorrow I will go on configuring it, now it’s getting too late.

The objective for today is building a clone of my postfix installation (from sakura to masako, two gentoo servers) and keep this clone updated daily. The cloned installation may carry additional domains and the domains coming from the other machine must be parked so they can be switched on only in case of need (major disaster).

Installing Postfix from sources

From http://www.postfix.org/ I check what is the latest stable version, which now is 2.2.10

$ wget http://postfix.it-austria.net/releases/official/postfix-2.2.10.tar.gz
$ tar xfvz postfix-2.2.10.tar.gz
$ cd postfix-2.2.10

Compiling it with MySQL support is essential for my needs, it can still be done as normal user, no root required.

$ make -f Makefile.init makefiles \
‘CCARGS=-DHAS_MYSQL -I/usr/include/mysql/’ \
‘AUXLIBS=-L/usr/lib/ -lmysqlclient -lz -lm’

No <db.h> include file found.
Install the appropriate db*-devel package first.

I proceeded to install the missing db header files and then executed again the above make command line, that this time gets executed successfully. Now I can

$ make
# make install

(I’ve accepted all defaults)

Configuring postfix

First I check if I’ve all the helper programs and install them via packages: clamav, amavisd-new, spamassassin (including razor). After that I gave a look to logs to be sure everything is going fine until now.

Copied MySQL tables from postfix database: bcc, transport, users, vacation, virtual and the script that writes local domains to /etc/postfix/local.domains ( /etc/cron.daily/local.domains.cron )

# rc-update add clamd default
# /etc/init.d/clamav start

Files synchronized once:

/etc/amavisd.conf

$myhostname = ‘sakura.obliquid.com’; -> $myhostname = ‘masako.obliquid.com’;

$log_level = 1; // 1 for the tests, 0 for production

# /etc/init.d/amavisd start ; tail -f /var/log/messages

> TROUBLE in pre_loop_hook: TEMPBASE directory is not writable: /var/amavis/tmp at /usr/sbin/amavisd line 6435.

# ls -lhd /var/amavis/tmp/
drwxr-x— 2 root root 72 May 21 00:14 /var/amavis/tmp/
# chown amavis.amavis /var/amavis/tmp/
# /etc/init.d/amavisd zap
# /etc/init.d/amavisd start ; tail -f /var/log/messages

> TROUBLE in pre_loop_hook: db_home directory is not writable: /var/amavis/db at /usr/sbin/amavisd line 6445.

# chown amavis.amavis /var/amavis/db
# /etc/init.d/amavisd zap
* Manually resetting amavisd to stopped state.
# /etc/init.d/amavisd start ; tail -f /var/log/messages

> TROUBLE in pre_loop_hook: QUARANTINEDIR directory not writable: /var/amavis/quarantine at /usr/sbin/amavisd line 6454.

# chown amavis.amavis /var/amavis/quarantine
# /etc/init.d/amavisd zap
* Manually resetting amavisd to stopped state.
# /etc/init.d/amavisd start ; tail -f /var/log/messages

This time looks good, so I added to the daemon to the startup list

# rc-update add amavisd default
* amavisd added to runlevel default
* rc-update complete.

Another file to copy and keep synchronized is /etc/spamassassin/local.cf

# ACCEPT_KEYWORDS=”~amd64″ emerge =pop-before-smtp-1.41

Configuration /etc/pop-before-smtp.pl to be copied only once

Configuration file /etc/syslog-ng/syslog-ng.conf to be copied only once

And now we can finally copy /etc/postfix/main.cf, where I changed:

message_size_limit = 50000000 -> 1000000
virtual_mailbox_limit = 1000000000 -> 10000000
mailbox_size_limit = 1000000000 -> 10000000
myhostname = sakura.obliquid.com -> masako.obliquid.com

other files copied once:

/etc/postfix/transport.cf
/etc/postfix/mysql_virt.cf
/etc/postfix/uids.cf
/etc/postfix/gids.cf
/etc/postfix/virtual.cf
/etc/postfix/bcc.cf
/etc/postfix/sender_bcc (commented out)
/etc/postfix/rbl-whitelist
/etc/postfix/master.cf

For the moment I’ve commented out mailman in both main.cf and master.cf

# postfix check
postfix/postfix-script: warning: not owned by group postdrop: /var/spool/postfix/public
postfix/postfix-script: warning: not owned by group postdrop: /var/spool/postfix/maildrop
postfix/postfix-script: warning: not owned by group postdrop: /usr/sbin/postqueue
postfix/postfix-script: warning: not owned by group postdrop: /usr/sbin/postdrop

# chgrp postdrop /var/spool/postfix/public
# chgrp postdrop /var/spool/postfix/maildrop
# chgrp postdrop /usr/sbin/postqueue
# chgrp postdrop /usr/sbin/postdrop
# chmod g+s /usr/sbin/postqueue
# chmod g+s /usr/sbin/postdrop

# postfix check

Now doesn’t give any errors! :-) Finally… going to test a daemon start
daemon started — version 2.2.10, configuration /etc/postfix

This is not an easy setup, but so far so good. Anyway there is still much to do, tomorrow I will start to move scripts to create mailboxes and start more tests.

Powered by WordPress Web Design by SRS Solutions © 2010 Stivlo'st in Asia Design by SRS Solutions