DEV01 - Using XML Services for Web Application Development

Christian Langanke for netlabs.org

Overview

Solution Demo






The Web Application

s

XML Basics and Features

Using XML within applications

Benefits of XML within applications

Solution Demo






Internal usage of XML

Access Web Services with SOAP

Sample XML service

Solution Demo





OpenLigaDB Service
SOAP XML Envelope
PHP access sample

Sample Web Application Layout

Sample Web Application Layout

Local Result Cacheing

Ways of determining cache expiration

Writing the Local Cache - Tasks

Writing the Local Cache - Sample

Example function for writing cache to a local file:

private function _writecache( $expiredate, $name,
                              $parm1, $parm2, $parm3,
                              $result)
{
$cachefilename =
  $this->_getcachefilename( $name, $parm1,
                            $parm2, $parm3);
$fh = fopen( $cachefilename, 'w');
if (!$fh) return false;

fputs( $fh, $expiredate);
fputs( $fh, "\n");
fputs( $fh, serialize( $result));
fclose( $fh);

return true;
}

Reading the Local Cache - Tasks

Reading the Local Cache - Sample

Example function for reading cache from a local file:

private function _readcache( $name, $parm1, 
                             $parm2, $parm3)
{
$cachefilename =
  $this->_getcachefilename( $name, $parm1,
                            $parm2, $parm3);
$fh = fopen( $cachefilename, 'r');
if (!$fh) return false;
$expiredate = trim( fgets( $fh));
$result = unserialize( trim (fgets( $fh)));
fclose( $fh);

$expiretime  = strtotime( $expiredate);
if (time() > $expiretime)
  return false;
return $result;
}

Using the Local Cache

In each service access method call

Using the Local Cache

Example service access method calling internal cache methods:

public function GetNextMatch()
{
$response = $this->_readcache( "GetNextMatch",
                               false, false, false);
if (!$response)
  {
  $params = new stdClass;
  $params->leagueShortcut = $this->LEAGUESHORTCUT;
  $response = $this->SOAPclient->GetNextMatch( $params);

  $dateexpire =
     $response->GetNextMatchResult->matchDateTime;
  $this->_writecache( $dateexpire, "GetNextMatch",
                      false, false, false, $response);
  }
return $result;
}

Solution Demo






Cache Usage

Session Close






Questions & Answers

The End






Thank you very much for your your attention!