Services_Webservice
The package will/should do all the annoying stuff that comes to you when creating webservices, like:
1) Simple example creates wsdl, disco, infopage and soapserver. Watch live !
-
include_once('Services/Webservice.php');
-
class myService extends Services_Webservice
-
{
-
/**
-
* Says "Hello!"
-
*
-
* @param int
-
* @return string
-
*/
-
public function hello($i )
-
{
-
//create some logic here
-
return 'myString';
-
}
-
}
-
-
$myService = new myService(
-
'myService',
-
'example webservice description',
-
);
-
$myService->handle();
2) A more advanced service with support for complex types. Watch live !
-
include_once('Services/Webservice.php');
-
class classB
-
{
-
/**
-
* @var string
-
*/
-
public $c;
-
-
public function __construct($c)
-
{
-
$this->c=$c;
-
}
-
}
-
-
class myService extends Services_Webservice
-
{
-
/**
-
* Says "Hello!"
-
*
-
* @param int
-
* @param string
-
* @return classB
-
*/
-
public function hello($i, $j )
-
{
-
//create some logic here
-
return new SoapVar(new ClassB('myString'),
-
SOAP_ENC_OBJECT,
-
'classB',
-
'urn:myService');
-
}
-
}
-
-
$myService = new myService(
-
'myService',
-
'example webservice description',
-
);
-
$myService->handle();
3) Using arrays. Watch live !
-
include_once('Services/Webservice.php');
-
class myService extends Services_Webservice
-
{
-
/**
-
* Says "Hello!"
-
*
-
* @param int[]
-
* @return string[]
-
*/
-
public function hello($i)
-
{
-
$strArray[] = $i[0].'a';
-
$strArray[] = $i[1].'b';
-
$strArray[] = $i[2].'c';
-
$strArray[] = $i[3].'d';
-
$strArray[] = $i[4].'e';
-
return $strArray;
-
}
-
}
-
-
$myService = new myService(
-
'myService',
-
'example webservice description',
-
);
-
$myService->handle();
4) Using arrays, complex types. Watch live !
-
include_once('Services/Webservice.php');
-
class classB
-
{
-
/**
-
* @var int[]
-
*/
-
public $i;
-
-
public function __construct()
-
{
-
}
-
}
-
class myService extends Services_Webservice
-
{
-
-
/**
-
* Says "Hello!"
-
*
-
* @return classB[]
-
*/
-
public function hello()
-
{
-
//create some business logic here
-
$classB[] = new SoapVar(new ClassB(),SOAP_ENC_OBJECT,'classB','urn:myService');
-
-
return $classB;
-
}
-
}
-
$myService = new myService(
-
'myService',
-
'example webservice description',
-
);
-
-
$myService->handle();
Please do not expect from the package to work properly yet. The wsdl-creating is quite stable. While doing some extensive test with .net-clients I discovered the wsdl is also used for typemapping the soap-messages. So the whole wsdl had to be recreated.

