cancel
Showing results for 
Search instead for 
Did you mean: 

Problem creating new Nodes with the PHP Library

plaico
Champ in-the-making
Champ in-the-making
There are two things I'd like to know about the PHP Library. Firstly, I could not manage it to create a new node using the following code:

$new_child = $currentNode->createChild('cm_content', 'cm_contains', 'cm_phpinfo.php');
$new_child->cm_name = 'phpinfo.php';
$new_child->setContent('cm_content', 'text/plain', 'UTF-8', 'blablabla');
I always get the the same error message:

Fatal error: Uncaught SoapFault exception: [soapenv:Server.generalException] WSDoAllReceiver: security 

processing failed; nested exception is: org.apache.ws.security.WSSecurityException: General security error

(WSSecurityEngine: Callback supplied no password for: username) in

/var/www/localhost/htdocs/alfrescophp/Alfresco/Service/WebService/AlfrescoWebService.php:67 Stack trace:

#0 /var/www/localhost/htdocs/alfrescophp/Alfresco/Service/WebService/AlfrescoWebService.php(67):

SoapClient->__soapCall('query', Array, Array, Array, Array) #1

/var/www/localhost/htdocs/alfrescophp/Alfresco/Service/WebService/AlfrescoWebService.php(49):

AlfrescoWebService->__soapCall('query', Array) #2 [internal function]: AlfrescoWebService->__call('query',

Array) #3 /var/www/localhost/htdocs/alfrescophp/Alfresco/Service/Session.php(226):

AlfrescoWebService->query(Array) #4

/var/www/localhost/htdocs/alfrescophp/Alfresco/Service/SpacesStore.php(48):

Session->query(Object(SpacesStore), 'PATH:"app:compa…') #5 /var/www/localhost/htdocs/alfrescoph in

/var/www/localhost/htdocs/alfrescophp/Alfresco/Service/WebService/AlfrescoWebService.php on line 67
Probably, some of the params are wrong, but I couldn't find anything about it in the documentation and all the other forum threads I looked at used the same code as I do.

The next thing I have problems with is the correct way to upload files. There is already a variable in the Node class but the SetContent-function has no line which would set a value to this variable. Therefore, I changed the function to set this variable but due to my first problem, I could not test this properly because I got to the same SOAPFault exception as above.
Are there any more examples?
18 REPLIES 18

danniemstanley
Champ in-the-making
Champ in-the-making
I receive the same error as the original poster.  It seems to be related to the browser session.  If I close the browser and then reload it, the exception goes away.  It seems that maybe the ticket is expiring on the server side before it expires on the client side?

Fatal error: Uncaught SoapFault exception: [soapenv:Server.generalException] WSDoAllReceiver: security processing failed; nested exception is: org.apache.ws.security.WSSecurityException: General security error (WSSecurityEngine: Callback supplied no password for: username) in C:\webdev\apps\inc\Alfresco\Service\WebService\AlfrescoWebService.php:65 Stack trace: #0 C:\webdev\apps\inc\Alfresco\Service\WebService\AlfrescoWebService.php(65): SoapClient->__soapCall('queryChildren', Array, Array, Array, Array) #1 C:\webdev\apps\inc\Alfresco\Service\WebService\AlfrescoWebService.php(47): AlfrescoWebService->__soapCall('queryChildren', Array) #2 [internal function]: AlfrescoWebService->__call('queryChildren', Array) #3 C:\webdev\apps\inc\Alfresco\Service\Node.php(480): AlfrescoWebService->queryChildren(Array) #4 C:\webdev\apps\inc\Alfresco\Service\Node.php(379): Node->populateChildren() #5 C:\webdev\apps\inc\Alfresco\Service\BaseObject.php(37): Node->getChildren() #6 C:\webdev\apps\inc\Alfresco\Service\Node.php(274): BaseObject- in C:\webdev\apps\inc\Alfresco\Service\WebService\AlfrescoWebService.php on line 65

mmariotti
Champ in-the-making
Champ in-the-making
Here's a way to create folder, doc and navigate from a point of the tree:

//create a folder in root alfresco root directory
      function createFol($currentNode,$session)
      {
        $new_child_store = $currentNode->createChild(
                                              'cm_folder',
                                              'cm_contains',
                                              'app_myStore'
        );
       
        $new_child_store->addAspect("cm_titled");
       
        $new_child_store->cm_name = 'myStore';
        $new_child_store->cm_title = "This is a title";
        $new_child_store->cm_description = "This is a description";
       
        $session->save();
     
      }    
     
//create a document in alfresco root directory
      function createDoc($store,$session)
      {
        $filename = "pippo_".time()."_.txt";
     
        $content_data = $store->getCompanyHome()->createChild(
                                                    "cm_content",
                                                    "cm_contains",
                                                    "cm_" .$filename
        );
       
        $content_data->cm_name = $filename;
       
        $content_data->cm_title = ("This is my new document.");
         $content_data->cm_description = ("tag1;tag2;tag3;");
         
        $content_data->setContent("cm_content", "text/plain", "UTF-8", "testTESTtestBlaBLABlaBla");
         
        $session->save();
        $nodeID = $content_data->id;
       
        $doc = $session->getNode($store, $nodeID);
       
        //print_r($doc->cm_name);               //–>PER VISUALIZZARE IL NOME DEL FILE
       
        $doc_view = $doc->cm_content;
        //print_r($doc_view->content);        //–>PER VISUALIZZARE IL CONTENUTO DEL FILE
      }
     
//navigate the tree from a point of the file system
      function navigate($store,$session)
      {
        $id = "6f44ec91-442c-11dc-944e-db4a961e19e4";     //naviga partendo dalla cartella Servizi Finanziari
        //$id = "7dbb786e-442c-11dc-944e-db4a961e19e4";   // naviga partendo dalla cartella Servizi Postali
       
        $node = $session->getNode($store, $id);
        foreach($node->children as $child)
        {
          if($child->child->type == "{http://www.alfresco.org/model/content/1.0}folder")
          {
            $id = $child->child->id;
          }
         
          if($child->child->type == "{http://www.alfresco.org/model/content/1.0}content")
          {
            $content = $child->child->cm_content;
            $id = $content->getUrl();
         
          }
         
          echo $id."  ";
          echo $child->child->cm_name."<br>";
       
        }
      }
//here i call the listed functions    
     //createFol($currentNode,$session);
     //createDoc($store,$session);
     //navigate($store,$session);

It works fine to me,
Hope it can help
mirko

hael
Champ in-the-making
Champ in-the-making
hi,

i get the same, unified soap (update) errors for totally different problems. how can i reveal a more specific description about the real, underlying problem, like
"file already exists" or "the space doesn't exists".

thx

hbf
Champ on-the-rise
Champ on-the-rise
Not a fix, but something that might help in finding out the cause of the problem: I've run into the same issue (original poster's exception "Callback supplied no password for: username") and found that when I remove my browser's cookies, everything works fine again.

Regards,
Kaspar

hbf
Champ on-the-rise
Champ on-the-rise
It seems to me that this thread is about several things: a session problem and how to create a content node from a file. Here's a piece of PHP code that does the latter and works for me.

  $name = 'blabla';
  $mime = 'application/pdf';
  $n = $home->createChild('cm_content', 'cm_contains', 'cm_'.$name);
  $n->cm_name = $name;
  $content = new ContentData($n, 'cm_content', $mime, 'UTF-8');
  $content->writeContentFromFile('/tmp/test.pdf');
  $n->cm_content = $content;
  $session->save();

Best,
Kaspar

hbf
Champ on-the-rise
Champ on-the-rise
… regarding the session problem. In my case, this hint helped me: I edited tomcat/conf/web.xml so that
<session-timeout>30</session-timeout>
does not contain 30 but some ridicuously large number. (Needless to say that this is not a good thing to do in a production environment, but it works around the problem at least.)

Hope this helps others as well,
Kaspar

antonella
Champ in-the-making
Champ in-the-making
it doesn't work neither this one..it gives me the same error..someone could help me please?

antonella
Champ in-the-making
Champ in-the-making
you mean i have to increase session timeout??

ofrxnz
Champ in-the-making
Champ in-the-making
I have similar problem when it comes to posting. files…..

The issue is not creating new nodes but trying to create/overwrite a node when one already exists with that name. 

any one have any ideas on how to update.

here is my error


Fatal error: Uncaught SoapFault exception: [soapenv:Server.generalException] (null) in C:\xampp\htdocs\joomla\components\com_alfrescodropbox\Alfresco\Service\WebService\AlfrescoWebService.php:65 Stack trace: #0 C:\xampp\htdocs\joomla\components\com_alfrescodropbox\Alfresco\Service\WebService\AlfrescoWebService.php(65): SoapClient->__soapCall('update', Array, Array, Array, Array) #1 C:\xampp\htdocs\joomla\components\com_alfrescodropbox\Alfresco\Service\WebService\AlfrescoWebService.php(47): AlfrescoWebService->__soapCall('update', Array) #2 [internal function]: AlfrescoWebService->__call('update', Array) #3 C:\xampp\htdocs\joomla\components\com_alfrescodropbox\Alfresco\Service\Session.php(168): AlfrescoWebService->update(Array) #4 C:\xampp\htdocs\joomla\components\com_alfrescodropbox\controller.php(64): Session->save() #5 C:\xampp\htdocs\joomla\components\com_alfrescodropbox\controller.php(96): AlfrescoDropBoxController->postFile() #6 C:\xampp\htdocs\joomla\libraries\joomla\application\component\controller.php(236): Alfres in C:\xampp\htdocs\joomla\components\com_alfrescodropbox\Alfresco\Service\WebService\AlfrescoWebService.php on line 65