/** * Create the service wrapper for a SCA Component. In the event that the mapping * of the SCA Component methods the base_class and xmldas types are set to * null. * * @param string $class_name * @param string $wsdl_filename */ public function __construct($instance, $class_name, $wsdl_filename) { SCA::$logger->log("Entering"); $this->class_name = $class_name; $this->instance_of_the_base_class = $instance; SCA::fillInReferences($this->instance_of_the_base_class); // create a JSON DAS and populate it with the valid types // that this service can create. Not strinctly required // for json encoding but the JSON Server uses this // DAS for decoding $xsds = SCA_Helper::getAllXsds($class_name); $this->json_das = new SDO_DAS_Json(); foreach ($xsds as $index => $xsds) { list($namespace, $xsdfile) = $xsds; if (SCA_Helper::isARelativePath($xsdfile)) { $xsd = SCA_Helper::constructAbsolutePath($xsdfile, $class_name); $this->json_das->addTypesXsdFile($xsd); } } }
/** * Create the service wrapper for a SCA Component. * * @param object $instance Instance * @param string $class_name Class * @param string $wsdl_filename WSDL */ public function __construct($instance, $class_name, $wsdl_filename) { SCA::$logger->log("Wrapper {$class_name}"); $this->class_name = $class_name; $this->instance_of_the_base_class = $instance; SCA::fillInReferences($this->instance_of_the_base_class); $this->annotations = new SCA_AnnotationReader($this->instance_of_the_base_class); // create an XML-RPC DAS and populate it with the valid types // that this service can create. $xsds = SCA_Helper::getAllXsds($class_name); $this->xmlrpc_das = new SCA_Bindings_Xmlrpc_DAS(); foreach ($xsds as $index => $xsds) { list($namespace, $xsdfile) = $xsds; if (SCA_Helper::isARelativePath($xsdfile)) { $xsd = SCA_Helper::constructAbsolutePath($xsdfile, $class_name); $this->xmlrpc_das->addTypesXsdFile($xsd); } } $this->xmlrpc_server = xmlrpc_server_create(); $service_description = $this->annotations->reflectService(); $serviceDescGen = new SCA_Bindings_Xmlrpc_ServiceDescriptionGenerator(); $serviceDescGen->addIntrospectionData($this->xmlrpc_server, $service_description, $this->method_aliases, $this->xmlrpc_das); }
/** * Generate method and type information to add introspection data. * The information required is generated from annotations. * All methods are registered with the server, and introspection data * is added to the server. * * @param resource $xmlrpc_server XML RPC server * @param array $service_description Description * @param array &$method_aliases Aliases * @param object $xmlrpc_das Unknown * * @return string Method description */ public function addIntrospectionData($xmlrpc_server, $service_description, &$method_aliases, $xmlrpc_das = null) { if ($xmlrpc_das == null) { $xsds = SCA_Helper::getAllXsds($service_description->class_name); $xmlrpc_das = new SCA_Bindings_Xmlrpc_DAS(); foreach ($xsds as $index => $xsds) { list($namespace, $xsdfile) = $xsds; if (SCA_Helper::isARelativePath($xsdfile)) { $xsd = SCA_Helper::constructAbsolutePath($xsdfile, $service_description->class_name); $xmlrpc_das->addTypesXsdFile($xsd); } } } $type_list = array(); $methodDesc = <<<END <?xml version='1.0'?> <introspection version='1.0'> <methodList> END; foreach ($service_description->operations as $methodName => $methodInfo) { $methodParams = ""; $methodReturn = ""; if (array_key_exists("name", $methodInfo) && array_key_exists("name", $methodInfo["name"]) && $methodInfo["name"]["name"] != null && strlen($methodInfo["name"]["name"]) > 0) { $xmlrpcMethodName = $methodInfo["name"]["name"]; $method_aliases[$xmlrpcMethodName] = $methodName; } else { $xmlrpcMethodName = $methodName; } xmlrpc_server_register_method($xmlrpc_server, $xmlrpcMethodName, $methodName); if (array_key_exists("parameters", $methodInfo) && $methodInfo["parameters"] != null) { foreach ($methodInfo["parameters"] as $param) { $paramName = $param["name"]; if (array_key_exists('objectType', $param)) { $paramType = $param["objectType"]; $this->generateType($param["namespace"], $param["objectType"], $type_list, $xmlrpc_das); } else { $paramType = $this->sdoTypeToXmlRpcType($param["type"]); } $methodParams = $methodParams . <<<END <value type='{$paramType}' desc='{$paramName}'> </value> END; } } if (array_key_exists("return", $methodInfo) && $methodInfo["return"] != null) { foreach ($methodInfo["return"] as $ret) { if (array_key_exists('objectType', $ret)) { $retType = $ret["objectType"]; $this->generateType($ret["namespace"], $ret["objectType"], $type_list, $xmlrpc_das); } else { $retType = $this->sdoTypeToXmlRpcType($ret["type"]); } $methodReturn = $methodReturn . <<<END <value type='{$retType}' desc='return'> </value> END; } } $methodDesc = $methodDesc . <<<END <methodDescription name='{$xmlrpcMethodName}'> <author></author> <purpose></purpose> <version></version> <signatures> <signature> <params> {$methodParams} </params> <returns> {$methodReturn} </returns> </signature> </signatures> </methodDescription> END; } $methodDesc = $methodDesc . "</methodList>\n"; if (count($type_list) > 0) { $methodDesc = $methodDesc . "<typeList>\n"; foreach ($type_list as $type) { $methodDesc = $methodDesc . <<<END <typeDescription name='{$type->name}' basetype='struct' desc='{$type->name}'> END; foreach ($type->typedef->properties as $prop) { $methodDesc = $methodDesc . <<<END <value type='{$prop->type}' name='{$prop->name}'></value> END; } $methodDesc = $methodDesc . <<<END </typeDescription> END; } $methodDesc = $methodDesc . "</typeList>\n"; } $methodDesc = $methodDesc . "</introspection>\n"; $descArray = xmlrpc_parse_method_descriptions($methodDesc); xmlrpc_server_add_introspection_data($xmlrpc_server, $descArray); }
/** * Get XML DAS for Atom * * @param string $class_name Class name * @param string $namespace_uri Namespace * * @todo refactor this back into getXmldas - should just be able to load the atom schema if the namespace and type are http://www.w3.org/2005/Atom and entryType. This needs some thought though as the namespace could change, and someone else might use the type name entryType in a non-atom schema * * @return XML_DAS */ public static function getXmldasForAtom($class_name, $namespace_uri) { SCA::$logger->log("Entering"); $xmldas = SDO_DAS_XML::create(dirname(__FILE__) . '/Atom1.0.xsd'); // expect to find xsds along with the SCA code - automatically loads xhtml1.xsd and xml.xsd as part of this. // TODO examine this code again // one might imagine that what is wanted is a map: // array(namespace => Set Of xsd) // but this is not what we have // Code Analyser correctly picks up a number // of strangenesses $xsds = SCA_Helper::getAllXsds($class_name); //$atomhelperlog->log("SCA_ServiceWrapperAtom::getXmldasForAtom() Just tried to find xsds in the component: ". print_r($xsds, true) ." \n"); //$xmldas = SDO_DAS_XML::create(); foreach ($xsds as $index => $xsds) { list($namespace, $xsdfile) = $xsds; if (SCA_Helper::isARelativePath($xsdfile)) { $xsd = SCA_Helper::constructAbsolutePath($xsdfile, $class_name); $xmldas->addTypes($xsd); } } // $atomhelperlog->log("SCA_ServiceWrapperAtom::getXmldasForAtom() xmldas after adding other types from the class:: $xmldas \n"); SCA::$logger->log("Exiting"); return $xmldas; }