mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
bc8cd107db
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73055 467b73ca-7a2a-4603-9d3b-597d59a354a9
73 lines
1.7 KiB
PHP
Executable File
73 lines
1.7 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Soap server class.
|
|
* See {@link SOAPModelAccess} for an auto-generated
|
|
* SOAP API for your models.
|
|
*
|
|
* @todo Improve documentation
|
|
* @package sapphire
|
|
* @subpackage integration
|
|
*/
|
|
class SapphireSoapServer extends Controller {
|
|
static $methods = array();
|
|
static $xsd_types = array(
|
|
'int' => 'xsd:int',
|
|
'boolean' => 'xsd:boolean',
|
|
'string' => 'xsd:string',
|
|
'binary' => 'xsd:base64Binary',
|
|
);
|
|
|
|
function wsdl() {
|
|
ContentNegotiator::disable();
|
|
header("Content-type: text/xml");
|
|
return array();
|
|
}
|
|
|
|
function getWSDLURL() {
|
|
return Director::absoluteBaseURLWithAuth() . $this->Link() . "wsdl";
|
|
}
|
|
|
|
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() {
|
|
$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();
|
|
}
|
|
}
|
|
|
|
?>
|