18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page.inc';
39 const SOAP_XML_SCHEMA_VERSION =
'http://www.w3.org/2001/XMLSchema';
40 const SOAP_XML_SCHEMA_INSTANCE =
'http://www.w3.org/2001/XMLSchema-instance';
41 const SOAP_SCHEMA_ENCODING =
'http://schemas.xmlsoap.org/soap/encoding/';
42 const SOAP_ENVELOP =
'http://schemas.xmlsoap.org/soap/envelope/';
43 const SCHEMA_SOAP_HTTP =
'http://schemas.xmlsoap.org/soap/http';
44 const SCHEMA_SOAP =
'http://schemas.xmlsoap.org/wsdl/soap/';
45 const SCHEMA_WSDL =
'http://schemas.xmlsoap.org/wsdl/';
46 const XML_CONTENT_TYPE =
'Content-Type: text/xml; charset=utf-8';
48 private $function_list = Array();
49 private $complex_types = Array();
50 private $complex_elements = Array();
51 private $simple_types = Array (
'float',
'int',
'string',
'boolean');
52 private $simple_restricted_types = Array();
54 private $message_node;
55 private $portType_node;
56 private $binding_node;
62 private $server_location;
74 $this->_ser_attrs = TRUE;
75 parent::__construct($assetid);
90 SQ_LINK_TYPE_2 => Array(
'soap_api' => Array(
'card' =>
'M',
'exclusive' => FALSE)),
91 SQ_LINK_TYPE_1 => Array(
'soap_api' => Array(
'card' =>
'M',
'exclusive' => FALSE)),
106 if (isset($_SERVER[
'REQUEST_METHOD']) && $_SERVER[
'REQUEST_METHOD'] ==
'POST') {
108 if (!isset($HTTP_RAW_POST_DATA)) {
109 $HTTP_RAW_POST_DATA = file_get_contents(
"php://input");
113 $logged_in = $this->authenticateHttpUser();
115 header(
'WWW-Authenticate: Basic realm="Squiz Matrix"');
116 header(
'HTTP/1.0 401 Unauthorized');
122 $this->
service($HTTP_RAW_POST_DATA);
124 $logged_in = $this->authenticateHttpUser();
127 header(
'WWW-Authenticate: Basic realm="Squiz Matrix"');
128 header(
'HTTP/1.0 401 Unauthorized');
133 if (isset($_SERVER[
'QUERY_STRING']) && strcasecmp($_SERVER[
'QUERY_STRING'],
'wsdl') == 0) {
137 parent::printFrontend();
151 private function authenticateHttpUser()
154 if (!(array_get_index($_SERVER,
'PHP_AUTH_USER') && array_get_index($_SERVER,
'PHP_AUTH_PW'))) {
158 if (!is_null($_SERVER[
'PHP_AUTH_USER'])) {
159 $auth_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'authentication_folder');
160 $auth_systems = $auth_folder->getAuthSystems();
163 foreach ($auth_systems as $systemid) {
164 $system = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($systemid);
165 if (is_null($system))
continue;
166 $user = $system->authenticateUser($_SERVER[
'PHP_AUTH_USER'], $_SERVER[
'PHP_AUTH_PW']);
167 if (!is_null($user)) {
168 $GLOBALS[
'SQ_SYSTEM']->loginUser($user);
175 unset($_SERVER[
'PHP_AUTH_USER']);
176 unset($_SERVER[
'PHP_AUTH_PW']);
191 ini_set(
"soap.wsdl_cache_enabled",
"0");
192 require_once dirname(__FILE__).
'/soap_server_error_handler.inc';
195 $old_error_handler = set_error_handler(
'soap_server_error_handler');
197 $server =
new SoapServer($this->data_path.
'/content_file.wsdl');
201 $dom =
new DOMDocument();
202 $dom->loadXML($HTTP_RAW_POST_DATA);
203 }
catch (Exception $e) {
204 throw new Exception(
'Unable to parse SOAP request "'.$HTTP_RAW_POST_DATA.
'": '.$e->getMessage());
208 $children = $dom->documentElement->childNodes;
210 $function_names = Array();
211 while ($children->item($i)) {
213 if (($children->item($i)->nodeType === 1) && (strpos($children->item($i)->tagName,
'Body'))) {
214 foreach ($children->item($i)->childNodes as $child) {
215 if ($child->nodeType === 1) {
216 $function_names[] = preg_replace(
'/(.*:)/',
'', $child->tagName);
224 $operations = $this->getAvailableOperations();
225 for ($i=0; $i < count($function_names); $i++) {
226 if (isset($operations[$function_names[$i]])) {
227 $class_name = $operations[$function_names[$i]][
'class_name'];
228 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($class_name);
229 $server->setClass($class_name);
235 restore_error_handler();
249 $available_operations = $this->getAvailableOperations(TRUE);
250 $list_api = $this->
attr(
'list_api');
251 if (!isset($_GET[
'desc'])) {
252 echo
'<ul style="list-style: circle;">';
253 foreach ($available_operations as $func_name => $class_info) {
255 <li style=
"padding-bottom:10px;">
256 <a href=
"<?php echo $_SERVER['PHP_SELF'].'?desc='.$func_name.'&group='.str_replace('soap_api_', '', $class_info['class_name']) ?>" style=
"color:#336699;font-weight:bold;font-size:13px;font-family:Tahoma;">
257 <?php echo ucwords($func_name) ?>
265 $func_name = $_GET[
'desc'];
266 if (isset($_GET[
'group'])) {
267 $group = $_GET[
'group'];
270 if (!empty($func_name) && !empty($group)) {
273 if (isset($available_operations[$func_name]) && $available_operations[$func_name][
'class_name'] ==
'soap_api_'.$group) {
274 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'soap_api_'.$group);
275 $class =
new ReflectionClass(str_replace(
' ',
'_', ucwords(str_replace(
'_',
' ',
'soap_api_'.$group))));
276 $method = $class->getMethod($func_name);
278 <script language=
"Javascript" type=
"text/javascript">
279 function revealEntry(baseloc,entryname) {
280 imagename =
"expand"+entryname;
281 if (document.getElementById(entryname).style.display ==
"none") {
282 document.getElementById(entryname).style.display =
"";
283 document[imagename].src = baseloc+
"/web/images/icons/internal_message/del.png";
286 document.getElementById(entryname).style.display =
"none";
287 document[imagename].src = baseloc+
"/web/images/icons/internal_message/add.png";
293 <span style=
"font-size:16px;font-family:tahoma;font-weight:bold;">
294 <?php echo (($method->isPublic()) ?
'Public ' :
'') ?>
296 <span style=
"color:#006699;font-size:16px;font-family:tahoma;font-weight:bold;">
297 <?php echo ucwords($func_name) ?>
301 $comment = $this->cleanComment($method->getDocComment());
302 $func_info = $this->getFuncDocInfo($comment);
307 preg_match(
'|(\w*)|', $group, $matches);
308 eval(
'$complexType = Soap_Api_'.ucwords($matches[1]).
'::getComplexElements();');
311 <span style=
"color:#000000;font-size:12px;font-family:tahoma;font-weight:normal;">
312 Description: <?php echo $func_info[
'func_desc'] ?>
318 if (isset($complexType[$func_name])) {
319 foreach ($complexType[$func_name] as $key => $args_info) {
320 if ($key ==
'arg_name') {
321 echo $this->_printFuncInfo(
'Argument Name: ', NULL,
'margin-left:15px;').$this->_printFuncInfo(NULL, $args_info).
'<br />';
323 echo $this->_printFuncInfo(NULL, $args_info[
'type'],
'margin-left:15px;').
' '.$this->_printFuncInfo($key.
': ').
'<br />';
327 echo $this->_printFuncInfo(
'Return type: ', NULL,
'margin-left:15px;').$this->_printFuncInfo(NULL, $func_info[
'return_type']).
'<br /><br />';
329 <a href=
"javascript:revealEntry('<?php echo sq_web_path('lib'); ?>','requestenvelope')" style=
"text-decoration:none;"><img name=
"expandrequestenvelope" src=
"<?php echo sq_web_path('lib'); ?>/web/images/icons/internal_message/del.png" border=
"0" /><span style=
"border:0;font-size:13px;font-family:tahoma;color:#0099FF;font-weight:bold;"> View Request Envelope</span></a><br /><br />
331 <div
id=
"requestenvelope" style=
"display:;margin-top:10px;margin-left:12px;margin-bottom:10px;">
333 if (isset($complexType[$func_name])) {
335 <span style=
"font-size:12px;font-family:tahoma;">
336 The <?php echo $this->_placeholder(
'Placeholder') ?> text should be replaced with the correct data
338 <div style=
"width:90%;margin-top:10px;padding:20px;padding-top:10px;padding-bottom:10px;background:#EEEEEE;color:#000000;font-size:12px;font-family:tahoma;font-weight:normal;">
339 <?php echo $this->_printRequestEnvelope($complexType[$func_name], $func_name); ?>
345 <a href=
"javascript:revealEntry('<?php echo sq_web_path('lib'); ?>','returnenvelope')" style=
"text-decoration:none;"><img name=
"expandreturnenvelope" src=
"<?php echo sq_web_path('lib'); ?>/web/images/icons/internal_message/del.png" border=
"0" /><span style=
"border:0;font-size:13px;font-family:tahoma;color:#0099FF;font-weight:bold"> View Response Envelope</span></a><br />
347 <div
id=
"returnenvelope" style=
"display:;margin-top:10px;margin-left:12px;margin-bottom:10px;">
349 if (isset($complexType[$func_name.
'Response'])) {
351 <span style=
"font-size:12px;font-family:tahoma;">
352 The <?php echo $this->_placeholder(
'Placeholder') ?> text should be replaced with the correct data
354 <div style=
"width:90%;margin-top:10px;padding:20px;padding-top:10px;padding-bottom:10px;background:#EEEEEE;color:#000000;font-size:12px;font-family:tahoma;font-weight:normal;">
355 <?php echo $this->_printResponseEnvelope($complexType[$func_name.
'Response'], $func_name); ?>
365 echo $this->_printFuncInfo(
'Service does not exists');
381 private function getAvailableOperations($saveToObject=FALSE)
384 $available_operations = Array();
386 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($this->
id,
'soap_api', FALSE);
387 $list_api = $this->
attr(
'list_api');
388 foreach ($children as $api_id => $type_info) {
389 if (!isset($list_api[$api_id]))
continue;
390 $child = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($api_id);
391 $type_code = $type_info[0][
'type_code'];
392 $functions = $child->attr(
'function_list');
394 foreach ($functions as $key => $value) {
395 $functions[$key] = Array (
396 'class_name' => $type_code,
400 $available_operations = array_merge($available_operations, $functions);
402 $this->complex_elements = array_merge($this->complex_elements, $child->getComplexElements($functions));
403 $this->complex_types = array_merge($this->complex_types, $child->getComplexTypes($functions));
404 $this->simple_restricted_types = array_merge($this->simple_restricted_types, $child->getSimpleRestrictedTypes($functions));
405 $this->function_list = $available_operations;
409 return $available_operations;
424 private function _printFuncInfo($title=NULL, $content=NULL, $extra=NULL)
427 if (!is_null($title)) {
428 $str =
'<span style="font-size:12px;font-family:tahoma;font-weight:bold;'.$extra.
'">'.$title.
'</span>';
429 }
else if (!is_null($content)) {
431 if (isset($this->simple_restricted_types[$content])) {
432 $restricted_values = $this->simple_restricted_types[$content][
'enumeration'];
433 sort($restricted_values);
434 $ele_notes = implode(
', ', $restricted_values);
436 $str =
'<span style="color:#006699;font-size:12px;font-family:tahoma;font-weight:bold;'.$extra.
'" title="'.$ele_notes.
'">'.$content.
'</span>';
452 private function _printRequestEnvelope($args_info, $func_name)
457 POST <?php echo $this->_placeholder($this->getUrl()) ?> HTTP/1.1<br />
458 Host: <?php echo $this->_placeholder(sq_root_url($this->getUrl(),FALSE)) ?><br />
459 Content-Type: <?php echo self::XML_CONTENT_TYPE ?><br />
460 Content-Length: <?php echo $this->_placeholder(
'length') ?><br />
466 <?xml version=
"1.0" encoding=
"utf-8" ?><br />
467 <soap:Envelope xmlns:xsi=
"<?php echo self::SOAP_XML_SCHEMA_INSTANCE ?>"
468 xmlns:ns1=
"<?php echo $this->getUrl() ?>"
469 xmlns:xsd=
"<?php echo self::SOAP_XML_SCHEMA_VERSION ?>"
470 xmlns:soap=
"<?php echo self::SOAP_ENVELOP ?>"><br />
472 <div style=
"padding-left:10px">
473 <soap:Body><br />
474 <div style=
"padding-left:10px">
475 <ns1:<?php echo $func_name ?>><br />
477 $this->printRequestResponseRecursive($args_info);
479 </ns1:<?php echo $func_name ?>><br />
481 </soap:Body><br />
483 </soap:Envelope><br />
486 $content = ob_get_contents();
500 private function printRequestResponseRecursive($args_info)
502 foreach ($args_info as $key => $arg_info) {
503 $io_type = (is_array($arg_info)) ? $arg_info[
'type'] :
'';
505 if ($io_type !==
'' && isset($this->complex_elements[$io_type])) $io_type =
'';
507 if (isset($this->simple_restricted_types[$io_type])) {
508 $restricted_values = $this->simple_restricted_types[$io_type][
'enumeration'];
509 sort($restricted_values);
511 $ele_notes = implode(
', ', $restricted_values);
513 ?><div style=
"padding-left:10px">
514 <<?php echo $key ?>><?php
if (!empty($io_type)) echo $this->_placeholder($io_type, $ele_notes);
517 if (!is_array($arg_info)) {
518 if (isset($this->complex_elements[$arg_info])) {
519 $this->printRequestResponseRecursive($this->complex_elements[$arg_info]);
520 }
else if (isset($this->simple_restricted_types[$arg_info])) {
521 echo $this->_placeholder($arg_info);
523 }
else if (is_array($arg_info)) {
529 if (isset($this->complex_elements[$arg_info[
'type']])) {
530 $this->printRequestResponseRecursive($this->complex_elements[$arg_info[
'type']]);
536 ?></<?php echo $key ?>>
553 private function _printResponseEnvelope($args_info, $func_name)
557 <span>HTTP/1.0 200 OK<br />
558 Date: <?php echo $this->_placeholder(date(
"D, j M Y h:i:s e")) ?><br />
559 Server: <?php echo $this->_placeholder(sq_root_url($this->getUrl(),FALSE)) ?><br />
560 Content-Type: <?php echo self::XML_CONTENT_TYPE ?><br />
561 Content-Length: <?php echo $this->_placeholder(
'length') ?><br />
567 <?xml version=
"1.0" encoding=
"utf-8" ?><br />
568 <soap:Envelope xmlns:xsi=
"<?php echo self::SOAP_XML_SCHEMA_INSTANCE ?>" <br />
569 xmlns:ns1=
"<?php echo $this->getUrl() ?>"
570 xmlns:xsd=
"<?php echo self::SOAP_XML_SCHEMA_VERSION ?>" xmlns:soap=
"<?php echo self::SOAP_ENVELOP ?>"><br />
573 <div style=
"padding-left:10px">
574 <soap:Body><br />
575 <div style=
"padding-left:10px">
576 <ns1:<?php echo $func_name.
'Response'; ?>><br />
578 <?php $this->printRequestResponseRecursive($args_info); ?>
580 </ns1:<?php echo $func_name.
'Response'; ?>><br />
582 </soap:Body><br />
584 </soap:Envelope><br />
588 $content = ob_get_contents();
604 private function _placeholder($name=
'', $title=
'')
606 if (empty($name)) $name=
' ';
608 $placeholder_tag1 =
'<span style="color:#003366;font-weight:bold;font-family:tahoma;font-size:12px;" title="'.$title.
'">';
609 $placeholder_tag2 =
'</span>';
611 return $placeholder_tag1.$name.$placeholder_tag2;
624 private function cleanComment($comment)
626 $comment = str_replace(
'/*',
'' , $comment);
627 $comment = str_replace(
'*/',
'' , $comment);
628 $comment = str_replace(
'*',
'' , $comment);
642 private function getWSDL()
644 header(self::XML_CONTENT_TYPE);
645 if (!file_exists($this->data_path.
'/content_file.wsdl')) {
648 $wsdl_content = file_get_contents($this->data_path.
'/content_file.wsdl');
649 if (!is_null($wsdl_content)) {
700 private function getXML()
702 $wsdl =
new DomDocument(
"1.0",
'utf-8');
705 $root = $wsdl->createElementNS(
'http://schemas.xmlsoap.org/wsdl/',
'wsdl:definitions');
706 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:s',
'http://www.w3.org/2001/XMLSchema');
707 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:tns', $this->getUrl());
708 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:soap',self::SCHEMA_SOAP);
709 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:wsdl',self::SCHEMA_WSDL);
710 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:soapenc',self::SOAP_SCHEMA_ENCODING);
711 $root->setAttribute(
'targetNamespace', $this->getUrl());
714 $types_node = $wsdl->createElementNS(self::SCHEMA_WSDL,
'types');
715 $this->schema_node = $wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'schema');
716 $this->schema_node->setAttribute(
'targetNamespace', $this->getUrl());
720 $this->portType_node = $wsdl->createElementNS(self::SCHEMA_WSDL,
'portType');
721 $this->portType_node->setAttribute(
'name',
'MatrixSOAPService');
724 $binding_node = $wsdl->createElementNS(self::SCHEMA_WSDL,
'binding');
725 $binding_node->setAttribute(
'name',
'MatrixSOAPServiceBinding');
726 $binding_node->setAttribute(
'type',
'tns:MatrixSOAPService');
729 $soap_binding_node = $wsdl->createElementNS(self::SCHEMA_SOAP,
'binding');
730 $soap_binding_node->setAttribute(
'style',
'document');
731 $soap_binding_node->setAttribute(
'transport', self::SCHEMA_SOAP_HTTP);
734 $binding_node->appendChild($soap_binding_node);
737 $this->binding_node = $binding_node;
747 $this->appendSimpleRestrictedTypes();
748 $this->appendComplexTypes();
749 $this->appendComplexElements();
752 $types_node->appendChild($this->schema_node);
753 $this->root->appendChild($types_node);
756 $io = Array (
'input',
'output');
757 foreach ($this->function_list as $func_name => $func_info) {
758 foreach ($io as $element) {
760 $this->message_node = $wsdl->createElementNS(self::SCHEMA_WSDL,
'message');
761 $this->message_node->setAttribute(
'name', $func_name.
'Soap'.ucwords($element)
763 $part_node = $wsdl->createElementNS(self::SCHEMA_WSDL,
'part');
764 $part_node->setAttribute(
'name',
'parameters');
768 $message_io = $simpleType ?
's:'.$func_info[
'arg_type'] :
'tns:'.$func_name.(($element ==
'output')?
'Response':
'');
769 $part_node->setAttribute(
'element', $message_io);
771 $this->message_node->appendChild($part_node);
772 $this->root->appendChild($this->message_node);
777 $this->root->appendChild($this->portType_node);
778 $this->root->appendChild($binding_node);
779 $this->appendService();
782 $wsdl->appendChild($root);
785 return $this->wsdl->saveXML();
802 $this->getAvailableOperations(TRUE);
806 foreach ($this->function_list as $func_name => $func_info) {
808 $class =
new ReflectionClass(str_replace(
' ',
'_', ucwords(str_replace(
'_',
' ', $func_info[
'class_name']))));
810 if (method_exists($func_info[
'class_name'], $func_name)) {
811 $input_output = Array (
'input',
'output');
814 $operation_node = $this->wsdl->createElementNS(self::SCHEMA_WSDL,
'operation');
815 $operation_node->setAttribute(
'name', $func_name);
816 $sub_operation_node = $this->wsdl->createElementNS(self::SCHEMA_SOAP,
'operation');
817 $sub_operation_node->setAttribute(
'soapAction',
'');
820 $operation_node_2 = clone $operation_node;
822 $operation_node->appendChild($sub_operation_node);
824 foreach ($input_output as $element) {
825 $io_node = $this->wsdl->createElementNS(self::SCHEMA_WSDL, $element);
826 $body_node = $this->wsdl->createElementNS(self::SCHEMA_SOAP,
'body');
827 $body_node->setAttribute(
'use',
'literal');
828 $io_node->appendChild($body_node);
829 $operation_node->appendChild($io_node);
832 $this->binding_node->appendChild($operation_node);
835 foreach ($input_output as $element) {
836 $io_message_node = $this->wsdl->createElementNS(self::SCHEMA_WSDL, $element);
837 $io_message_node->setAttribute(
'message',
'tns:'.$func_name.
'Soap'.ucwords($element));
838 $operation_node_2->appendChild($io_message_node);
840 $this->portType_node->appendChild($operation_node_2);
843 $method = $class->getMethod($func_name);
844 $doc_comment = $method->getDocComment();
847 $func_args_info = $this->getFuncDocInfo($doc_comment);
850 $this->function_list[$func_name] = array_merge($func_info, $func_args_info);
867 private function getFuncDocInfo($doc_comment)
871 preg_match_all(
'|@param\s+(\w+)\s+(\&)?\$(\w+)|', $doc_comment, $matches);
873 $func_args_info = Array (
874 'arg_type' => isset($matches[1][0]) ? $matches[1][0] :
'',
875 'arg_ref' => isset($matches[2][0]) ? $matches[2][0] :
'',
876 'arg_name' => isset($matches[3][0]) ? $matches[3][0] :
'',
879 $matches_0 = Array();
880 preg_match_all(
'|Description:\s+((\w+\s)*)|', $doc_comment, $matches_0);
881 $func_args_info[
'func_desc'] = isset($matches_0[1][0]) ? trim($matches_0[1][0]) :
'';
883 $matches_2 = Array();
884 preg_match(
'|@return\s+(\w+)|', $doc_comment, $matches_2);
885 $func_args_info[
'return_type'] = $matches_2[1];
887 return $func_args_info;
899 private function appendComplexElements()
902 foreach ($this->complex_elements as $func_io => $sub_args_info) {
905 $func_name_safe = str_replace(
'Response',
'', $func_io);
906 if (!array_key_exists($func_name_safe, $this->function_list))
continue;
909 $element_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'element');
910 $element_node->setAttribute(
'name', $func_io);
912 $complex_main_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'complexType');
915 $sequence_main_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'sequence');
918 foreach ($sub_args_info as $sub_arg_name => $info) {
920 $subelement_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'element');
921 $subelement_node->setAttribute(
'name', $sub_arg_name);
922 if (strtolower($info[
'type']) ==
'any') {
923 $sub_complex_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'complexType');
924 $sub_sequence_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'sequence');
925 if ($info[
'mixed']) {
926 $sub_complex_node->setAttribute(
'mixed', $info[
'mixed'] ?
"true" :
"false");
928 $any_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'any');
929 $sub_sequence_node->appendChild($any_node);
930 $sub_complex_node->appendChild($sub_sequence_node);
931 $subelement_node->appendChild($sub_complex_node);
933 $subelement_node->setAttribute(
'type', (!in_array($info[
'type'], $this->simple_types) ?
'tns:' :
's:' ).$info[
'type']);
935 $subelement_node->setAttribute(
'minOccurs', (!is_array($info)) ?
'1': $info[
'min']);
936 $subelement_node->setAttribute(
'maxOccurs', (!is_array($info)) ?
'1': $info[
'max']);
937 if ($info[
'nillable']) {
938 $subelement_node->setAttribute(
'nillable', strtolower((
string) $info[
'nillable']));
941 $sequence_main_node->appendChild($subelement_node);
944 $complex_main_node->appendChild($sequence_main_node);
945 $element_node->appendChild($complex_main_node);
950 $this->schema_node->appendChild($element_node);
964 private function appendComplexTypes()
967 foreach ($this->complex_types as $func_io => $sub_args_info) {
969 $complex_type_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'complexType');
970 $complex_type_node->setAttribute(
'name', $func_io);
971 if (is_array($sub_args_info)) {
972 $sequence_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'sequence');
973 foreach ($sub_args_info as $sub_arg_name => $info) {
974 if ($sub_arg_name ==
'arg_name')
continue;
975 $subelement_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'element');
976 $subelement_node->setAttribute(
'name', $sub_arg_name);
979 if (!empty($info[
'type'])) {
980 $subelement_node->setAttribute(
'type', (!in_array($info[
'type'], $this->simple_types) ?
'tns:' :
's:' ).$info[
'type']);
982 $subelement_node->setAttribute(
'minOccurs', $info[
'min']);
983 $subelement_node->setAttribute(
'maxOccurs', $info[
'max']);
984 if ($info[
'nillable']) {
985 $subelement_node->setAttribute(
'nillable', strtolower((
string) $info[
'nillable']));
987 if ($info[
'mixed']) {
988 $subelement_node->setAttribute(
'mixed', strtolower((
string) $info[
'mixed']));
991 $sequence_node->appendChild($subelement_node);
993 $complex_type_node->appendChild($sequence_node);
996 $complex_type_node->setAttribute(
'type',
'tns:'.$sub_args_info);
1000 $this->schema_node->appendChild($complex_type_node);
1013 private function appendSimpleRestrictedTypes()
1016 foreach ($this->simple_restricted_types as $simple_restricted_type_name => $sub_args_info) {
1018 $simple_restricted_type_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'simpleType');
1019 $simple_restricted_type_node->setAttribute(
'name', $simple_restricted_type_name);
1020 if (is_array($sub_args_info)) {
1021 $restriction_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'restriction');
1022 $restriction_base = in_array($sub_args_info[
'restriction_base'], $this->simple_types) ?
's:'.$sub_args_info[
'restriction_base'] : $sub_args_info[
'restriction_base'];
1023 $restriction_node->setAttribute(
'base', $restriction_base);
1024 if (isset($sub_args_info[
'enumeration']) && is_array($sub_args_info[
'enumeration'])) {
1025 foreach ($sub_args_info[
'enumeration'] as $enum_val) {
1026 $enum_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'enumeration');
1027 $enum_node->setAttribute(
'value', $enum_val);
1028 $restriction_node->appendChild($enum_node);
1030 }
else if (isset($sub_args_info[
'pattern'])) {
1031 $pattern_node = $this->wsdl->createElementNS(self::SOAP_XML_SCHEMA_VERSION,
'pattern');
1032 $pattern_node->setAttribute(
'value', $sub_args_info[
'pattern']);
1033 $restriction_node->appendChild($pattern_node);
1035 $simple_restricted_type_node->appendChild($restriction_node);
1038 $simple_restricted_type_node->setAttribute(
'type',
'tns:'.$sub_args_info);
1042 $this->schema_node->appendChild($simple_restricted_type_node);
1055 private function appendService()
1058 $service_node = $this->wsdl->createElementNS(self::SCHEMA_WSDL,
'service');
1059 $service_node->setAttribute(
'name',
'MatrixWebServices');
1061 $port_node = $this->wsdl->createElementNS(self::SCHEMA_WSDL,
'port');
1062 $port_node->setAttribute(
'name',
'MatrixWebServicesPort');
1063 $port_node->setAttribute(
'binding',
'tns:MatrixSOAPServiceBinding');
1065 $address_node = $this->wsdl->createElementNS(self::SCHEMA_SOAP,
'address');
1066 $address_node->setAttribute(
'location', $this->getUrl().
'?wsdl');
1068 $port_node->appendChild($address_node);
1069 $service_node->appendChild($port_node);
1072 $this->root->appendChild($service_node);
1082 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1083 $wsdl_content = $this->getXML();
1084 create_directory($this->data_path);
1085 return string_to_file($wsdl_content, $this->data_path.
'/content_file.wsdl');