API -> SoapClient Error

Discussion in 'ISPConfig 3 Priority Support' started by mib007, Jul 27, 2017.

  1. mib007

    mib007 New Member HowtoForge Supporter

    Hi,
    I worked on a API Script. I want to delete an Additional Template from a User.
    So I called client_template_additional_delete but I get allways the followig error:
    Code:
    #0 /var/www/clients/client2/web41/web/ispconfig.php(131): SoapClient->__call('client_template...', Array) #1 {main}
    The following Code I used:
    PHP:
       try{
            
    /* Connect to SOAP Server */
            
    $client = new SoapClientnull,
                                array( 
    'location' => $soap_url,
                                        
    'uri' => $soap_uri,
                                        
    'exceptions' => 1,
                                        
    'stream_context'=> stream_context_create(
                                                array(
    'ssl'=> array(
                                                    
    'verify_peer'=>false,
                                                    
    'verify_peer_name'=>false))
                                                ),
                                            
    'trace' => false
                                        
    )
                                    );
            
    /* Authenticate with the SOAP Server */
            
    $session_id $client->login$soapuser$soappassword ); 
       } catch (
    SoapFault $e) {
              
    $error 'SOAP Error: ' $e->getMessage();
        }

       try{
           
    $client_templates $client->client_template_additional_delete($session_id,'30','3') ;
        } catch (
    Exception $e) {
            
    print_r($e->getTraceAsString()) ;
        }
    Any suggestion for me? What am I doing wrong?
    Greets
     
    Last edited: Jul 27, 2017
  2. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Try setting trace to true so you might get better hint to what is wrong.
     
  3. mib007

    mib007 New Member HowtoForge Supporter

    Hi,
    nothing happend with
    PHP:
    'trace' => true
    Same error message. ( #0 /var/www/clients/client2/web41/web/ispconfig.php(131): SoapClient->__call('client_template...', Array) #1 {main} )
     
  4. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Try add 'allow_self_signed'=>true to the ssl context options.
     
  5. mib007

    mib007 New Member HowtoForge Supporter

    Hi,
    done, nothing changed. Any other api call I preform going without any error.
    PHP:
        $record $client->get_function_list($session_id);
        
    print_r($record) ;
    give me the function list. It seems to be a problem with "client_template_additional_delete".
    "client_template_additional_add" also with no problem.
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    It is possible that this function has an issue then, when the other functions work.
     
  7. mib007

    mib007 New Member HowtoForge Supporter

    Any idea what issue and how to fix.
    Iam using the lastest ISPConfig version and Debian 9 with php7
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Not really. As a first step, you might ant to look at the apache error.log of the ispconfig server if you find any corresponding errors there. If there are no errors, then you might have to add some debug code into the function itself to see why and where it fails. the remote functions are in the files in /usr/local/ispconfig/interface/lib/classes/remote.d/
     
  9. mib007

    mib007 New Member HowtoForge Supporter

    Ok,
    I will do some debug and will look into the error.log
     
  10. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

  11. mib007

    mib007 New Member HowtoForge Supporter

    Hi,
    you are a bit faster! (Danke für die schnelle Hilfe ;) )!
    I found the same Solution, but it take a moment longer. Now it works!
     
    Croydon likes this.
  12. mib007

    mib007 New Member HowtoForge Supporter

    Ok, one last time. I found a bug
    At the moment:
    PHP:
     $sql "DELETE FROM `client_template_assigned` WHERE `assigned_template_id` = ? AND `client_id` = ?";
     
    $app->db->query($sql$assigned_template_id$client_id);
     
    $affected_rows $app->db->affectedRows();
    NEW:
    PHP:
       $sql "DELETE FROM `client_template_assigned` WHERE `assigned_template_id` = ? AND `client_id` = ?";
       
    $app->db->query($sql$check$client_id);
       
    $affected_rows $app->db->affectedRows();
    The 'assigned_template_id' field in the database is not the same as the '$assigned_template_id' var that we send to the api.
    (Auf Deutsch: An die API wird ja die template_id (aus der DB 'client_template_id') übergeben. Diese id ist nicht die selbe wie die assigned_template_id (diese ist einmalig). Diese wird zusätzlich ja noch beim Check abgefragt, daher passt es sich ganz gut, wie ich dachte.)
    Is that right, or I am wrong?
     
  13. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Not sure about this. Deleting normally is done by the primary id of an entry, but in this case it might make more sense using the template id as you suggested.
     
  14. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

Share This Page