2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
2008-02-25 03:10:37 +01:00
|
|
|
/**
|
2009-03-14 20:09:00 +01:00
|
|
|
* Soap server class.
|
|
|
|
* See {@link SOAPModelAccess} for an auto-generated
|
|
|
|
* SOAP API for your models.
|
|
|
|
*
|
2008-03-03 00:24:10 +01:00
|
|
|
* @todo Improve documentation
|
2008-02-25 03:10:37 +01:00
|
|
|
* @package sapphire
|
|
|
|
* @subpackage integration
|
|
|
|
*/
|
2007-07-19 12:40:28 +02:00
|
|
|
class SapphireSoapServer extends Controller {
|
|
|
|
static $methods = array();
|
|
|
|
static $xsd_types = array(
|
|
|
|
'int' => 'xsd:int',
|
2008-08-11 05:03:52 +02:00
|
|
|
'boolean' => 'xsd:boolean',
|
2007-07-19 12:40:28 +02:00
|
|
|
'string' => 'xsd:string',
|
|
|
|
'binary' => 'xsd:base64Binary',
|
|
|
|
);
|
|
|
|
|
|
|
|
function wsdl() {
|
|
|
|
ContentNegotiator::disable();
|
|
|
|
header("Content-type: text/xml");
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getWSDLURL() {
|
2008-08-11 05:03:52 +02:00
|
|
|
return Director::absoluteBaseURLWithAuth() . $this->Link() . "wsdl";
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function Methods() {
|
|
|
|
foreach($this->stat('methods') as $methodName => $arguments) {
|
|
|
|
$returnType = $arguments['_returns'];
|
|
|
|
unset($arguments['_returns']);
|
|
|
|
|
|
|
|
$processedArguments = array();
|
|
|
|
foreach($arguments as $argument => $type) {
|
|
|
|
$processedArguments[] = new ArrayData(array(
|
|
|
|
"Name" => $argument,
|
|
|
|
"Type" => self::$xsd_types[$type],
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
$methods[] = new ArrayData(array(
|
|
|
|
"Name" => $methodName,
|
|
|
|
"Arguments" => new DataObjectSet($processedArguments),
|
|
|
|
"ReturnType" => self::$xsd_types[$returnType],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
return new DataObjectSet($methods);
|
|
|
|
}
|
|
|
|
function TargetNamespace() {
|
|
|
|
return Director::absoluteBaseURL();
|
|
|
|
}
|
|
|
|
function ServiceURL() {
|
|
|
|
return Director::absoluteBaseURLWithAuth() . $this->class . '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
function index() {
|
2009-03-04 04:44:11 +01:00
|
|
|
$wsdl = $this->getViewer('wsdl')->process($this);
|
|
|
|
$wsdlFile = TEMP_FOLDER . '/sapphire-wsdl-' . $this->class;
|
|
|
|
$fh = fopen($wsdlFile, 'w');
|
|
|
|
fwrite($fh, $wsdl);
|
|
|
|
fclose($fh);
|
|
|
|
|
|
|
|
$s = new SoapServer($wsdlFile);
|
|
|
|
$s->setClass($this->class);
|
|
|
|
$s->handle();
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-04 04:44:11 +01:00
|
|
|
?>
|