Beispiel #1
0
    private function setUpXmlRpcTypes($xmlrpc_das)
    {
        $typeList = <<<END
<introspection>
    <typeList>

        <typeDescription name='SimpleType' basetype='struct' desc='Simple type'>
    
            <value type='int' name='intValue'></value>
            <value type='double' name='doubleValue'></value>
            <value type='string' name='strValue'></value>

        </typeDescription>

        <typeDescription name='ComplexType' basetype='struct' desc='Complex type'>

            <value type='SimpleType []' name='objArrValue'></value>
            <value type='int []' name='intArrValue'></value>
            <value type='int' name='intValue'></value>
            <value type='double' name='doubleValue'></value>
            <value type='string' name='strValue'></value>
            <value type='SimpleType' name='objValue'></value>

        </typeDescription>
    </typeList>
</introspection>
END;
        $call = <<<END
<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
    <methodName>system.describeMethods</methodName>
    <params/>
</methodCall>
END;
        $xmlrpc_server = xmlrpc_server_create();
        $descArray = xmlrpc_parse_method_descriptions($typeList);
        xmlrpc_server_add_introspection_data($xmlrpc_server, $descArray);
        $response = xmlrpc_server_call_method($xmlrpc_server, $call, null);
        xmlrpc_server_destroy($xmlrpc_server);
        $methodDesc = xmlrpc_decode_request($response, $method);
        $this->xmlrpc_das->addTypesXmlRpc($methodDesc["typeList"]);
    }
    /**
     * 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);
    }
Beispiel #3
0
 /**
  * Register an XmlRpcRequestHandler for this server instance
  *
  * @param XmlRpcRequestHandler $handler
  */
 public function registerHandler(XmlRpcRequestHandler $handler)
 {
     $this->handler = $handler;
     foreach (get_class_methods($handler) as $method) {
         if (!strncmp($method, "xmlrpc", 6)) {
             $this->registerMethod($this->method($method, $handler->getNamespace()), array($handler, $method), array($this, "dispatch"));
         }
     }
     $handler->getIntrospectionData($spec);
     if (is_array($spec)) {
         xmlrpc_server_add_introspection_data(self::$xmlrpc, $spec);
     }
 }