• Strange error thrown by the createSimple function

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #31565  by Skitter
 
Here's my PHP script:
Code: Select all
<?php
$OKMAuth = new SoapClient('http://localhost:8080/OpenKM/services/OKMAuth?wsdl');
$OKMDocument = new SoapClient('http://localhost:8080/OpenKM/services/OKMDocument?wsdl');
$loginResp = $OKMAuth->login(array('user' => 'okmAdmin', 'password' => 'mypass'));
$token = $loginResp->return;

foreach (glob("/home/test/*") as $filename) {
    $handle = fopen($filename,'rb');
    $file_content = fread($handle,filesize($filename));
    fclose($handle);
    try{
        $OKMDocument->createSimple($token,"/okm:root/file.to.upload",$file_content);
    }
    catch (Exception $e){
        echo $e->getMessage();
    }
  }
$OKMAuth->logout($token);
?>
All I'm trying to do is to send all files from /home/test/ to the /okm:root/ directory. I'm aware of the fact, that they will be overwritten because the file name is constant ('file.to.upload'). The problem is that the createSimple() function is throwing an error which says "Fault occurred while processing.". What am I doing wrong?
 #31566  by Skitter
 
Damn, sorry for my ignorance. I figured out how to do that. I have to pass the argument list as an array. Here's working code:
Code: Select all
<?php
$OKMAuth = new SoapClient('http://localhost:8080/OpenKM/services/OKMAuth?wsdl');
$OKMDocument = new SoapClient('http://localhost:8080/OpenKM/services/OKMDocument?wsdl');
$loginResp = $OKMAuth->login(array('user' => 'okmAdmin', 'password' => 'mypass'));
$token = $loginResp->return;

foreach (glob("/home/test/*") as $filename) {
    $handle = fopen($filename,'rb');
    $file_content = fread($handle,filesize($filename));
    fclose($handle);
    try{
    	$OKMDocument->createSimple(array('token' => $token, 'docPath' => '/okm:root/blahblah', 'content' => $file_content));
    }
    catch (Exception $e){
        echo $e->getMessage();
    }
}
$OKMAuth->logout($token);
?>

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.