32 const TNS =
'http://wcmf.sourceforge.net';
34 private $application =
null;
35 private $serverResponse =
'';
37 private static $logger =
null;
43 if (self::$logger ==
null) {
47 $endpoint = dirname($scriptURL).
'/soap';
48 $this->configureWSDL(
'SOAPService', self::TNS, $endpoint,
'document');
49 $this->wsdl->schemaTargetNamespace =
self::TNS;
50 $this->debugLevel = 9;
53 $this->wsdl->addComplexType(
60 [[
'ref' =>
'SOAP-ENC:arrayType',
'wsdl:arrayType' =>
'xsd:string[]']],
64 $this->wsdl->addComplexType(
71 [[
'ref' =>
'SOAP-ENC:arrayType',
'wsdl:arrayType' =>
'tns:SearchResultItem[]']],
72 'tns:SearchResultItem'
75 $this->wsdl->addComplexType(
'SearchResultItem',
'complexType',
'struct',
'sequence',
'', [
76 'type' => [
'name' =>
'type',
'type' =>
'xsd:string'],
77 'oid' => [
'name' =>
'oid',
'type' =>
'xsd:string'],
78 'displayValue' => [
'name' =>
'displayValue',
'type' =>
'xsd:string'],
79 'summary' => [
'name' =>
'summary',
'type' =>
'xsd:string']
86 $this->application->initialize();
88 catch (\Exception $ex) {
89 $this->handleException($ex);
97 if (self::$logger->isDebugEnabled()) {
98 self::$logger->debug($data);
101 $oldErrorReporting = error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
104 ob_start(
function($buffer) {
105 $this->serverResponse = $buffer;
108 parent::service($data);
110 error_reporting($oldErrorReporting);
111 if (self::$logger->isDebugEnabled()) {
112 self::$logger->debug($this->serverResponse);
115 catch (\Exception $ex) {
116 $this->handleException($ex);
125 $headerStrings = headers_list();
128 foreach ($headerStrings as $header) {
129 list($name, $value) = explode(
':', $header, 2);
130 $headers[trim($name)] = trim($value);
140 return $this->serverResponse;
158 public function doCall($action, $params) {
159 if (self::$logger->isDebugEnabled()) {
160 self::$logger->debug(
"SoapServer action: ".$action);
161 self::$logger->debug($params);
163 $authHeader = $this->requestHeader[
'Security'][
'UsernameToken'];
166 $request->setAction(
'actionSet');
167 $request->setFormat(
'soap');
168 $request->setResponseFormat(
'null');
169 $request->setValues([
174 'user' => $authHeader[
'Username'],
175 'password' => $authHeader[
'Password'][
'!']
191 $response = $this->application->run($request);
192 if ($response->hasErrors()) {
193 $errors = $response->getErrors();
197 $responseData = $response->getValue(
'data');
198 $data = $responseData[
'action2'];
199 $actionResponse->setSender($data[
'controller']);
200 $actionResponse->setContext($data[
'context']);
201 $actionResponse->setAction($data[
'action']);
202 $actionResponse->setFormat(
'soap');
203 $actionResponse->setValues($data);
205 $formatter->serialize($actionResponse);
206 if (self::$logger->isDebugEnabled()) {
207 self::$logger->debug($actionResponse->__toString());
211 catch (\Exception $ex) {
212 $this->handleException($ex);
214 return $actionResponse;
221 private function handleException($ex) {
222 self::$logger->error($ex->getMessage().
"\n".$ex->getTraceAsString());
223 $this->fault(
'SOAP-ENV:SERVER', $ex->getMessage(),
'',
'');