#!/usr/bin/php openInput($xml); $xmlExtractor->extractElement(InputExtractor::EC_BEG, $elem, $value, $attrs); $xmlExtractor->extractElement(InputExtractor::EC_BEG, $elem, $value, $attrs); if ($elem != "action") throw new Exception("Invalid xml format"); $interface = $attrs["interface"]; $procedure = $attrs["procedure"]; if (array_key_exists("path", $attrs)) { set_include_path($attrs["path"] . PATH_SEPARATOR . get_include_path()); } $params = array(); $ctl = $xmlExtractor->extractElement(InputExtractor::EC_BEG, $elem, $value, $attrs); while ($ctl != InputExtractor::EC_END) { $params[$attrs["name"]] = $attrs["value"]; $ctl = $xmlExtractor->extractElement($ctl, $elem, $value, $attrs); } // check action $proc_arr = Config::getInstance()->requireConfig($interface); if (!array_key_exists ( $procedure , $proc_arr )) { echo "Procedure $procedure does not exist in Interface $interface.\n"; throw new Exception("Error occurred"); } // check parameters $par_ord = $proc_arr[$procedure]; $akt_params = array(); foreach ($par_ord as $par_nam => $par_config) { if ($par_nam != "returns") { // returns is key word for return type if (array_key_exists ( $par_nam , $params )) { if (array_key_exists("Class", $par_config )) { $param_cls = new ReflectionClass($par_config["Class"]); array_push($akt_params, $param_cls->newInstance($params[$par_nam])); } else { array_push($akt_params, $params[$par_nam]); } } else { if (!in_array("optional", $par_config)) throw new Exception("Parameter $par_nam does not exist\n"); array_push($akt_params, null); } } } // invoke interface $if_cls = new ReflectionClass($interface); $if = $if_cls->newInstance(); $if_func = new ReflectionMethod($interface, $procedure); $ret_val = $if_func->invokeArgs($if, $akt_params); // check return value if (array_key_exists("returns", $par_ord)) { $ret_type = $par_ord["returns"]; switch ($ret_type) { case "ReturnValue": if (array_key_exists ( "ReturnValue" , $params )) $soll = $params["ReturnValue"]; else $soll = 0; if ($ret_val != $soll) throw new Exception("$interface::$procedure returned with value $ret_val instead of $soll."); break; case "void": break; case "xml": if (substr($ret_val, 0, 5) != "