Пример #1
0
 public function getParametersNames($wsdlUri, $operation)
 {
     global $prefs;
     $parameters = array();
     if (!$wsdlUri || !$operation) {
         return $parameters;
     }
     $context = null;
     if ($prefs['use_proxy'] == 'y' && !strpos($wsdlUri, 'localhost')) {
         // Use proxy
         $context = stream_context_create(array('http' => array('proxy' => $prefs['proxy_host'] . ':' . $prefs['proxy_port'], 'request_fulluri' => true)));
     }
     // Copy content in cache
     $wsdl_data = file_get_contents($wsdlUri, false, $context);
     if (!isset($wsdl_data) || empty($wsdl_data)) {
         trigger_error(tr("No WSDL found"));
         return array();
     }
     $wsdlFile = $GLOBALS['tikipath'] . 'temp/cache/' . md5($wsdlUri);
     file_put_contents($wsdlFile, $wsdl_data);
     // Read wsdl from local copy
     $wsdl = new wsdl('file:' . $wsdlFile);
     if (!empty($wsdl->error_str)) {
         trigger_error($wsdl->error_str);
         return $parameters;
     }
     $data = $wsdl->getOperationData($operation);
     if (isset($data['input']['parts'])) {
         foreach ($data['input']['parts'] as $parameter => $type) {
             preg_match('/^(.*)\\:(.*)\\^?$/', $type, $matches);
             if (count($matches) == 3 && ($typeDef = $wsdl->getTypeDef($matches[2], $matches[1]))) {
                 if (isset($typeDef['elements'])) {
                     foreach ($typeDef['elements'] as $element) {
                         $parameters[] = $typeDef['name'] . ':' . $element['name'];
                     }
                 }
             } else {
                 $parameters[] = $parameter;
             }
         }
     }
     return $parameters;
 }