mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-01 07:17:48 +02:00
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
class SapphireSoapServer extends Controller {
|
||
|
static $methods = array();
|
||
|
static $xsd_types = array(
|
||
|
'int' => 'xsd:int',
|
||
|
'string' => 'xsd:string',
|
||
|
'binary' => 'xsd:base64Binary',
|
||
|
);
|
||
|
|
||
|
function wsdl() {
|
||
|
ContentNegotiator::disable();
|
||
|
header("Content-type: text/xml");
|
||
|
return array();
|
||
|
}
|
||
|
|
||
|
function getWSDLURL() {
|
||
|
return Director::absoluteBaseURLWithAuth() . $this->class . "/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() {
|
||
|
$s = new SoapServer($this->getWSDLURL());
|
||
|
$s->setClass($this->class);
|
||
|
$s->handle();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
?>
|