Page 1 of 1

Web services create folder problem

PostPosted:Mon Nov 19, 2012 12:35 pm
by fuzzyq
Hi,

I try write some script to digital sign documents from php. But i have a problem with OKMFolder service i can't create any folder from php.

Simple script:
Code: Select all
<?php
  $OKMAuth = new SoapClient('http://192.168.1.106:8080/OpenKM/services/OKMAuth?wsdl');
  $OKMFolder = new SoapClient('http://192.168.1.106:8080/OpenKM/services/OKMFolder?wsdl');

  // Login
  $loginResp = $OKMAuth->login(array('user' => 'okmAdmin', 'password' => 'admin'));
  $token = $loginResp->return;
  echo "Token: ".$token."<br>";
 
// Create folder
  $createResp = $OKMFolder->create($token, '/okm:root/test');

  // Logout
  $OKMAuth->logout(array('token' => $token));
?>
I always get this error:
Code: Select all
Fatal error: Uncaught SoapFault exception: [soap:Server] Fault occurred while processing. in C:\xampp\htdocs\okmtest\aa.php:16 Stack trace: #0 C:\xampp\htdocs\okmtest\aa.php(16): SoapClient->__call('create', Array) #1 C:\xampp\htdocs\okmtest\aa.php(16): SoapClient->create(Array) #2 {main} thrown in C:\xampp\htdocs\okmtest\aa.php on line 16
Sorry for my english.

Regards

Re: Web services create folder problem

PostPosted:Tue Nov 20, 2012 12:06 am
by miguelromero
Check the correct function name and variable parameters to create a folder in the open xml which shows all the accesible functions for each class:
http://192.168.1.106:8080/OpenKM/servic ... older?wsdl

What you need is createSimple, not create function :D
create function has a lot more parameters.

You can also use try and catch to get the exception error message, as its shown in the openkm wiki for php.

Re: Web services create folder problem

PostPosted:Wed Nov 21, 2012 6:39 am
by fuzzyq
OK, but how?

I search parameters everywhere and i can't understand what a must use.

Can you give some example of create folder. I use OpenKM ver 6.20

That help me a lot.

Regards

Re: Web services create folder problem

PostPosted:Wed Nov 21, 2012 5:33 pm
by miguelromero
I will publish a full class with a lot more options soon but until then here you go:
Code: Select all
//CREATE folder, basic call
	public function OpenKM_createfolder($surlOpenKM, $token, $fldPath)
	{
		$bRet = 0;
		$okmurl = $surlOpenKM; //"http://".$sIP.":".$sport."/OpenKM/";
		if (isset($okmurl) && isset($token) && isset($fldPath))
		{
			try
			{
				$OKMFolder = new SoapClient($okmurl . "services/OKMFolder?wsdl");
				$OKMFolder->createSimple(array('token' => $token, 'fldPath' => $fldPath));
				$bRet = 1;
			}
			catch (Exception $e)
			{
				self::format_exception($e);
			}
		}
		return $bRet;
	}

Re: Web services create folder problem

PostPosted:Thu Nov 22, 2012 7:38 am
by fuzzyq
That's all what i need and it's working very well.
Thank you that was very helpful.

Regards!