Source for file disco_server.php
Documentation is available at disco_server.php
* This example shows how to mark up a server object so that WSDL files may be
* dynamicaly generated by the SOAP server. This also provides access to a
* generated DISCO document. The fact that this example has an MP3 class is
* in no way related to DISCO. ;)
* DISCO: http://msdn.microsoft.com/msdnmag/issues/02/02/xml/default.aspx
* Urls accessing this server would look like:
* - http://localhost/disco_server.php?wsdl (generate WSDL file)
* - http://localhost/disco_server.php (GET request generates DISCO)
* - http://localhost/disco_server.php (POST for normal SOAP requests)
* LICENSE: This source file is subject to version 2.02 of the PHP license,
* that is bundled with this package in the file LICENSE, and is available at
* through the world-wide-web at http://www.php.net/license/2_02.txt. If you
* did not receive a copy of the PHP license and are unable to obtain it
* through the world-wide-web, please send a note to license@php.net so we can
* mail you a copy immediately.
* @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more
* @author Jan Schneider <jan@horde.org> Maintenance
* @copyright 2003-2007 The PHP Group
* @license http://www.php.net/license/2_02.txt PHP License 2.02
* @link http://pear.php.net/package/SOAP
require_once 'SOAP/Server.php';
var $__dispatch_map = array ();
var $__typedef = array ();
/* The only way to describe all methods in WSDL (messages,
* PortType-operations and bindings) is to use __dispatch_map to
* describe every method (even methods using simple data types in 'in'
* and 'out' parameters...) */
$this->__dispatch_map['SayHallo'] =
array ('in' => array ('input' => 'string'),
'out' => array ('return' => 'string'));
$this->__dispatch_map['SayThisNTimes'] =
array ('in' => array ('SayThis'=> 'string','NTimes' => 'int'),
'out' => array ('return' => '{urn:MP3DB}ArrayOfStrings'));
$this->__dispatch_map['GetMP3Tracks'] =
array ('in' => array ('query' => 'string'),
'out' => array ('return' => '{urn:MP3DB}GetMP3TracksResult'));
$this->__dispatch_map['AddMP3Track'] =
array ('in' => array ('MP3Track' => '{urn:MP3DB}MP3Track'),
'out' => array ('return' => '{urn:MP3DB}AddMP3TrackResult'));
/* Use __typedef to describe userdefined Types in WSDL. Structs and
* one-dimensional arrays are supported.
* $this->__typedef['TypeName'] = array('VarName' => 'xsdType', ... );
* $this->__typedef['TypeName'] = array('VarName' => '{namespace}SomeOtherType');
* $this->__typedef['TypeName'] = array(array('item' => 'xsdType'));
* $this->__typedef['TypeName'] = array(array('item' => '{namespace}SomeOtherType'));
$this->__typedef['MP3Track'] =
array ('Title' => 'string',
'Orig_Artist' => 'string',
'Encoded_by' => 'string');
/* MP3TracksArray - array of 'MP3Track' structs. */
$this->__typedef['MP3TracksArray'] =
array (array ('item' => '{urn:MP3DB}MP3Track'));
/* Struct 'MethodDebug'. */
$this->__typedef['MethodDebug'] =
/* Return Struct of method GetMP3Tracks. */
$this->__typedef['GetMP3TracksResult'] =
array ('MethodDebug' => '{urn:MP3DB}MethodDebug',
'MP3Tracks' => '{urn:MP3DB}MP3TracksArray');
/* Return Struct of method AddMP3Track. */
$this->__typedef['AddMP3TrackResult'] =
array ('MethodDebug' => '{urn:MP3DB}MethodDebug');
$this->__typedef['ArrayOfStrings'] =
array (array ('item'=> 'string'));
return 'Hello, ' . $name;
for ($i = 0; $i < $NTimes; $i++ ) {
$return[$i] = $SayThis . ' ' . $i;
return new SOAP_Value('return', '{urn:MP3DB}ArrayOfStrings', $return);
for ($i = 0; $i < 5; $i++ ) {
array ('Title' => new SOAP_Value('Title', 'string', 'some track $i'),
'Artist' => new SOAP_Value('Artist', 'string', 'some artist $i'),
'Album' => new SOAP_Value('Album', 'string', 'some album $i'),
'Comment' => new SOAP_Value('Comment', 'string', 'blabla $i'),
'Composer' => new SOAP_Value('Composer', 'string', ''),
'Orig_Artist' => new SOAP_Value('Orig_Artist', 'string', ''),
'Encoded_by' => new SOAP_Value('Encoded_by', 'string', '')));
$MethodDebug['rc'] = new SOAP_Value('rc', 'boolean', true );
$MethodDebug['ErrNo'] = new SOAP_Value('ErrNo', 'int', 0 );
$MethodDebug['Error'] = new SOAP_Value('Error', 'string', '');
'{urn:MP3DB}GetMP3TracksResult',
array ('MethodDebug' => new SOAP_Value('MethodDebug', '{urn:MP3DB}MethodDebug',$MethodDebug),
'MP3Tracks' => new SOAP_Value('MP3Tracks', '{urn:MP3DB}MP3TracksArray',$this->MP3Tracks)));
/* Well, let's imagine here some code for adding given mp3track to db
$MethodDebug['rc'] = new SOAP_Value('rc', 'boolean', true );
$MethodDebug['ErrNo'] = new SOAP_Value('ErrNo', 'int', 0 );
$MethodDebug['Error'] = new SOAP_Value('Error', 'string', '');
'{urn:MP3DB}AddMP3TrackResult',
array ('MethodDebug' => new SOAP_Value('MethodDebug', '{urn:MP3DB}MethodDebug', $MethodDebug)));
if (isset ($this->__dispatch_map[$methodname])) {
return $this->__dispatch_map[$methodname];
$server->_auto_translation = true;
$server->addObjectMap ($MP3DB_Class, 'urn:MP3DB');
if (isset ($_SERVER['REQUEST_METHOD']) &&
$_SERVER['REQUEST_METHOD'] == 'POST') {
$server->service ($HTTP_RAW_POST_DATA);
require_once 'SOAP/Disco.php';
header('Content-type: text/xml');
if (isset ($_SERVER['QUERY_STRING']) &&
strpos($_SERVER['QUERY_STRING'], 'wsdl') !== false ) {
Documentation generated on Mon, 04 Aug 2008 20:00:18 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|