/** * Takes all parts of the given type and appends its fields to the given name. * This happend recursively down to builtin types. * Example: * $name = point * $type = Point (with the fields x and y) * result: * - point.x * - point.y * * @param string $name * The fields of the type are added to this name, separated by a dot. * @param string $type * The name of an XSD base type or a type defined in the WSDL. * @param SoapClient $wsClient * * @param array<string> $typePath * This array contains all types that were encountered in the recursion. * To avoid an inifinite loop, the recursion stops if $type is already * in the $typePath. This parameter is omitted in the top level call. * @return array<string> * All resulting paths. If a path causes an endless recursion, the * keyword ##overflow## is appended to the path. */ public static function flattenParam($name, $type, $wsClient, &$typePath = null) { //I made this method public and static and also //added the parameter $wsClient so that it is accessible //via the ajax interface //add initial xpath root if (strpos($name, "/") === false) { $name = "//" . $name; } $flatParams = array(); if (!$wsClient->isCustomType($type) && substr($type, 0, 7) != "ArrayOf") { // $type is a simple type $flatParams[] = $name; return $flatParams; } if (substr($type, 0, 7) == "ArrayOf") { if ($wsClient->isCustomType(substr($type, 7))) { //$flatParams[] = $name."[*]"; $flatParams[] = $name; return $flatParams; } } $tp = $wsClient->getTypeDefinition($type); foreach ($tp as $var => $type) { if (substr($type, 0, 7) == "ArrayOf") { $type = substr($type, 7); //$fname = ($name == "//") ? "//".$var."[*]" : $name.'/'.$var."[*]"; $fname = $name == "//" ? "//" . $var : $name . '/' . $var; } else { $fname = $name == "//" ? "//" . $var : $name . '/' . $var; } if ($wsClient->isCustomType($type)) { if (!$typePath) { $typePath = array(); } if (in_array($type, $typePath)) { // stop recursion $flatParams[] = $fname . "##overflow##"; continue; } $typePath[] = $type; $names = WebService::flattenParam($fname, $type, $wsClient, $typePath); $flatParams = array_merge($flatParams, $names); array_pop($typePath); } else { $flatParams[] = $fname; } } return $flatParams; }