Exemple #1
0
function deserializationAction(&$body)
{
    $data = $body->getValue();
    //Get the method that is being called
    $description = xmlrpc_parse_method_descriptions($data);
    $target = $description['methodName'];
    $baseClassPath = $GLOBALS['amfphp']['classPath'];
    $lpos = strrpos($target, '.');
    $methodname = substr($target, $lpos + 1);
    $trunced = substr($target, 0, $lpos);
    $lpos = strrpos($trunced, ".");
    if ($lpos === false) {
        $classname = $trunced;
        $uriclasspath = $trunced . ".php";
        $classpath = $baseClassPath . $trunced . ".php";
    } else {
        $classname = substr($trunced, $lpos + 1);
        $classpath = $baseClassPath . str_replace(".", "/", $trunced) . ".php";
        // removed to strip the basecp out of the equation here
        $uriclasspath = str_replace(".", "/", $trunced) . ".php";
        // removed to strip the basecp out of the equation here
    }
    $body->methodName = $methodname;
    $body->className = $classname;
    $body->classPath = $classpath;
    $body->uriClassPath = $uriclasspath;
    $body->packageClassMethodName = $description['methodName'];
}
Exemple #2
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"]);
    }
 /**
  * get the XML response of the XMLRPC server
  *
  * @return string the XML response
  */
 public function getResponse()
 {
     try {
         if ($this->signatureChecking) {
             $tmp = xmlrpc_parse_method_descriptions($GLOBALS['HTTP_RAW_POST_DATA']);
             $methodName = $tmp['methodName'];
             $parameters = xmlrpc_decode($GLOBALS['HTTP_RAW_POST_DATA'], $this->encoding);
             $method = $this->callHandler->getMethod($methodName);
             if (!$method) {
                 // see http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php for standard error codes
                 return XML_RPC2_Backend_Php_Response::encodeFault(-32601, 'server error. requested method not found');
             }
             if (!$method->matchesSignature($methodName, $parameters)) {
                 return XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters');
             }
         }
         set_error_handler(array('XML_RPC2_Backend_Xmlrpcext_Server', 'errorToException'));
         $response = @xmlrpc_server_call_method($this->_xmlrpcextServer, $GLOBALS['HTTP_RAW_POST_DATA'], null, array('output_type' => 'xml', 'encoding' => $this->encoding));
         restore_error_handler();
         return $response;
     } catch (XML_RPC2_FaultException $e) {
         return XML_RPC2_Backend_Php_Response::encodeFault($e->getFaultCode(), $e->getMessage());
     } catch (Exception $e) {
         return XML_RPC2_Backend_Php_Response::encodeFault(1, 'Unhandled ' . get_class($e) . ' exception:' . $e->getMessage());
     }
 }
    /**
     * 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);
    }
<?php

$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<a>
 <b>foo</b>
</a>
XML;
var_dump(xmlrpc_parse_method_descriptions($xml));