podoc:webservice
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
podoc:webservice [2007/04/13 14:19] – created Luud | podoc:webservice [2007/04/13 21:13] (current) – Luud | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== Photo Organizer Webservice ===== | ===== Photo Organizer Webservice ===== | ||
+ | |||
+ | By Luud Heck, April 2007 | ||
+ | |||
+ | ** NOTE: at this moment this page is little more than a dump of some things I've tested and proven to work. I have made further advances already and will update this page as soon as possible. ** | ||
==== Introduction ==== | ==== Introduction ==== | ||
Line 6: | Line 10: | ||
Below I explain how I publish my websites with MediaWiki and include Photo Organizer photos and albums in my wiki pages. The crux is that the information about photos and albums will be provided by Photo Organiser as a SOAP based webservice. | Below I explain how I publish my websites with MediaWiki and include Photo Organizer photos and albums in my wiki pages. The crux is that the information about photos and albums will be provided by Photo Organiser as a SOAP based webservice. | ||
+ | |||
==== MediaWiki ==== | ==== MediaWiki ==== | ||
Line 242: | Line 247: | ||
Here is the CSS file that needs to be imported in the wiki skin CSS file (use the import directive and place it at the start of the main.css file in the monobook skin for example). | Here is the CSS file that needs to be imported in the wiki skin CSS file (use the import directive and place it at the start of the main.css file in the monobook skin for example). | ||
< | < | ||
- | content still needs to be entered | + | /* |
+ | * Photo Organizer Extension Styling | ||
+ | */ | ||
+ | |||
+ | /* | ||
+ | * Do not float the album container, but keep it an inline element! | ||
+ | */ | ||
+ | div.po_album { | ||
+ | float: none; | ||
+ | width: 100%; | ||
+ | /* background-color: | ||
+ | border: 1px solid red; */ | ||
+ | clear: | ||
+ | } | ||
+ | |||
+ | .po_thumbnail { | ||
+ | margin: 0px; | ||
+ | padding: 0px; | ||
+ | } | ||
+ | |||
+ | /* | ||
+ | * Make sure to float the thumnails (left or right). | ||
+ | */ | ||
+ | div.po_thumbnail { | ||
+ | float: left; | ||
+ | border: 0px solid gray; | ||
+ | padding: 3px; | ||
+ | margin: 3px; | ||
+ | } | ||
+ | |||
+ | table.po_thumbnail, | ||
+ | /* border: 1px solid red; */ | ||
+ | border: 0px; | ||
+ | padding: 0px; | ||
+ | margin: 0px; | ||
+ | width: 100%; | ||
+ | height: 100%; | ||
+ | } | ||
+ | |||
+ | td.po_thumbnail { | ||
+ | text-align: center; | ||
+ | vertical-align: | ||
+ | } | ||
+ | |||
+ | img.po_thumbnail { | ||
+ | border: 1px solid black; | ||
+ | } | ||
</ | </ | ||
+ | |||
+ | |||
+ | ==== Photo Organizer SOAP interface ==== | ||
+ | |||
+ | Having the basics of creating a MediaWiki extension for Photo Organizer working, lets look at how we can make this extension retrieve information from the Photo Organizer database. | ||
+ | |||
+ | === PHP-SOAP === | ||
+ | |||
+ | Recent versions of PHP include good support for the SOAP protocol in the form of the [[http:// | ||
+ | |||
+ | Now, before you start experimenting, | ||
+ | |||
+ | **Make sure to disable WSDL caching in both client and server, and check every time that it is still there! ** | ||
+ | |||
+ | < | ||
+ | |||
+ | I thought I had it disabled, but trying things and starting over once in a while resulted in not having WSDL caching disabled in my client. This oversight has cost me a couple of evenings getting thing to work right. | ||
+ | |||
+ | Next tip: | ||
+ | |||
+ | ** Validate your WSDL file! ** | ||
+ | |||
+ | If you have Mono installed on your Linux box you can use the wsdl command. | ||
+ | |||
+ | Here is an example static serverice that generates some kind of Photo Organizer album information. This is just a demonstration, | ||
+ | |||
+ | photoorganizer.wsdl | ||
+ | < | ||
+ | <?xml version=' | ||
+ | < | ||
+ | targetNamespace=' | ||
+ | xmlns=' | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | |||
+ | <types xmlns=' | ||
+ | <schema xmlns=' | ||
+ | targetNamespace=' | ||
+ | |||
+ | < | ||
+ | <all> | ||
+ | <element name=" | ||
+ | <element name=' | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | ref=" | ||
+ | wsdl: | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <message name=' | ||
+ | <part name=' | ||
+ | </ | ||
+ | |||
+ | <message name=' | ||
+ | <part name=' | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | < | ||
+ | <input message=' | ||
+ | <output message=' | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <binding name=' | ||
+ | < | ||
+ | transport=' | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | use=' | ||
+ | encodingStyle=' | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | use=' | ||
+ | encodingStyle=' | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <service name=' | ||
+ | <port name=' | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | common.php | ||
+ | < | ||
+ | <?php | ||
+ | |||
+ | $wsdlfile = " | ||
+ | |||
+ | $photoClassMap = array ( | ||
+ | " | ||
+ | ); | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | photoinfo.php | ||
+ | < | ||
+ | <?php | ||
+ | |||
+ | /** | ||
+ | * The C_PhotoInfo class contains details for a single photo. | ||
+ | */ | ||
+ | class C_PhotoInfo { | ||
+ | /** @var int */ | ||
+ | public $id; | ||
+ | |||
+ | /** @var string */ | ||
+ | public $title; | ||
+ | } | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | photoserver.php | ||
+ | < | ||
+ | <?php | ||
+ | |||
+ | /** | ||
+ | * Manages remote requests for Photo Organizer | ||
+ | * | ||
+ | * This is the server for our Photo Organizer WebService. | ||
+ | */ | ||
+ | class C_PhotoOrganizerService { | ||
+ | |||
+ | /** | ||
+ | * Returns the list of photos in the specified album. | ||
+ | * | ||
+ | * @return photoInfoList[] | ||
+ | */ | ||
+ | public function getAlbum($id) { | ||
+ | $l_PhotoInfoList = array(); | ||
+ | |||
+ | // Let's make up some test data: | ||
+ | |||
+ | | ||
+ | |||
+ | $l_PhotoInfo-> | ||
+ | $l_PhotoInfo-> | ||
+ | |||
+ | $l_PhotoInfoList[0] = $l_PhotoInfo; | ||
+ | |||
+ | | ||
+ | |||
+ | $l_PhotoInfo-> | ||
+ | $l_PhotoInfo-> | ||
+ | |||
+ | | ||
+ | |||
+ | return $l_PhotoInfoList; | ||
+ | // return $l_PhotoInfo; | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | server.php | ||
+ | < | ||
+ | <?php | ||
+ | |||
+ | include_once " | ||
+ | include_once " | ||
+ | include_once " | ||
+ | |||
+ | ini_set(' | ||
+ | $s = new SoapServer( | ||
+ | ' | ||
+ | array( | ||
+ | ' | ||
+ | ' | ||
+ | ) | ||
+ | ); | ||
+ | $s-> | ||
+ | $s-> | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | client.php | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | <pre> | ||
+ | <?php | ||
+ | |||
+ | include_once " | ||
+ | include_once " | ||
+ | |||
+ | class client { | ||
+ | |||
+ | private $link; | ||
+ | |||
+ | public function __construct($wsdl) | ||
+ | { | ||
+ | global $photoClassMap; | ||
+ | |||
+ | $this-> | ||
+ | $wsdl, | ||
+ | array( | ||
+ | ' | ||
+ | ' | ||
+ | ) | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | public function getAlbum($id) | ||
+ | { | ||
+ | // $l_Album = array(); | ||
+ | |||
+ | try { | ||
+ | $l_Album = $this-> | ||
+ | |||
+ | echo " | ||
+ | var_dump ($l_Album); | ||
+ | |||
+ | echo " | ||
+ | |||
+ | // If only one element is returned, an array won't be built | ||
+ | if (is_array($l_Album)) | ||
+ | { | ||
+ | echo " | ||
+ | |||
+ | $i = 1; | ||
+ | foreach ($l_Album as $photo) | ||
+ | { | ||
+ | echo " | ||
+ | print_r ($photo); | ||
+ | $i++; | ||
+ | } | ||
+ | echo " | ||
+ | |||
+ | } else { | ||
+ | print_r ($l_Album); | ||
+ | } | ||
+ | } | ||
+ | catch (SoapFault $sf) | ||
+ | { | ||
+ | print_r ($sf-> | ||
+ | $this-> | ||
+ | } | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | public function debug() | ||
+ | { | ||
+ | echo " | ||
+ | print_r ($this-> | ||
+ | echo " | ||
+ | echo htmlspecialchars(str_replace('>', | ||
+ | echo " | ||
+ | echo htmlspecialchars(str_replace('>', | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | ini_set(' | ||
+ | |||
+ | echo " | ||
+ | |||
+ | echo " | ||
+ | |||
+ | $client = new client($wsdlfile); | ||
+ | $client-> | ||
+ | |||
+ | echo " | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ |
podoc/webservice.1176473987.txt.gz · Last modified: 2007/04/13 14:19 by Luud