Implementing SOAP example to create a website.

Discussion in 'Developers' Forum' started by moglia, Feb 22, 2010.

  1. moglia

    moglia New Member

    Hello i try implement a SOAP client to add some sites on batch rotine to ispconfig 3 need migrate many sites. Database script with soap works nice.

    I try run and no need SSL fields if you complete the SSL fields run without any problem if you not do it you be recive this error:

    Error: ssl_state_error_regex<br>
    ssl_locality_error_regex<br>
    ssl_organisation_error_regex<br>
    ssl_organistaion_unit_error_regex<br>
    ssl_country_error_regex<br>

    Anyway completing all fields the website created not show on panel. It´s strange because i try run to create again with the same domain name and recive this error:

    Error: domain_error_unique<br>


    Code:
    <?php
    
    $username = '';
    $password = '';
    
    $soap_location = '';
    $soap_uri = '';
    
    $client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri));
    
    try {
        
        if($session_id = $client->login($username,$password)) {
            echo "Logged:".$session_id."<br />\n";
    	}
      
    	$domain_name = "superdomainxxx1.com";
    	
    	$params['server_id'] = 1;
    	$params['ip_address'] = "";
    	$params['domain'] = $domain_name;
    	$params['type'] = 'Site'; //Site / Alias
    	$params['parent_domain_id']="";
    	$params['vhost_type'] = 'Namebased'; //Namebased / IP-Based
    	$params['hd_quota'] = '100';
    	$params['cgi'] = 'n'; //n // y
    	$params['ssi'] = 'n';//n / y
    	$params['suexec'] = 'n'; //n / y
    	$params['errordocs'] = 1; //0 / 1
    	$params['subdomain'] = 'www.'; //none / www. / *.
    	$params['ssl'] = 'n'; //n / y
    	$params['php'] = 'Mod-PHP'; //Disabled, Fast-CGI, CGI, Mod-PHP, SuPHP
    	$params['active'] = 'y'; //n / y
    	$params['redirect_type'] = 'No redirect'; //array('' => 'No redirect', 'no' => 'No flag', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L')
    	$params['redirect_path'] = '';
        $params['ssl_action'] = 'None';
        
    	/*$params['ssl_state'] = 'RJ';
    	$params['ssl_locality'] = 'Locale';
    	$params['ssl_organisation'] = 'Organization';
    	$params['ssl_organisation_unit'] = 'Dpto Tecnologia';
    	$params['ssl_country'] = 'BR';
    	$params['ssl_domain'] = 'ispconfigtest.com';
    	$params['ssl_request'] = '';
        $params['ssl_cert'] = '';
    	$params['ssl_bundle'] = '';
        $params['ssl_action'] = 'None'; //array('' => 'None', 'save' => 'Save Certificate', 'create' => 'Create Certificate','del' => 'Delete Certificate')*/
    
    	$client_id = 1;
    	$website_id = $client->sites_web_domain_add($session_id, $client_id, $params);
    	
    	if($client->logout($session_id)) {
    		echo "Logout.<br />\n";
    	}
    	
    	
    }
    catch (SoapFault $e) {
    	die('Error: '.$e->getMessage());
    }
    
    ?>
    
    Regards 4 any
    antecipated help.
     
  2. till

    till Super Moderator

    check if you have a client with id 1. Login as admin user and check again if the site shows up, use the search function too.
     
  3. till

    till Super Moderator

    Compare the record in the web_domain table of the non working website with a working website.
     
  4. moglia

    moglia New Member

    Is on database!

    Code:
    mysql> select domain,active from web_domain;
    +----------------------------+--------+
    | domain                     | active |
    +----------------------------+--------+
    | ispconfigtest.com          | y      |
    | crazydomainxxx.com         | y      |
    +----------------------------+--------+
    5 rows in set (0.00 sec)
    
    is on database, but don´t show on control panel. and directories don´t be created.
     
    Last edited: Feb 22, 2010
  5. till

    till Super Moderator

    Please do what I recommended in #4. Compare the record of w working website with the record of a not working website.
     
  6. moglia

    moglia New Member

    One question.

    Code:
    'vhost_type' => array (
    			'datatype'	=> 'VARCHAR',
    			'formtype'	=> 'SELECT',
    			'default'	=> 'y',
    			'value'		=> array('name' => 'Namebased', 'ip' => 'IP-Based')
    
    Some times 'value' use the value or aways use the key to record?
     
  7. till

    till Super Moderator

    This depends on the formtype.

    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)

    = value

    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY

    = array
     
  8. moglia

    moglia New Member

    Question II

    Code:
    'active' => array (
    			'datatype'	=> 'VARCHAR',
    			'formtype'	=> 'CHECKBOX',
    			'default'	=> 'y',
    			'value'		=> array(0 => 'n',1 => 'y')
    		),
    
    I try to pass 0 or 1 because the field is from type CHECKBOX. i pass 1 and recorded active = N.
    I pass Y and recorded active without any problems. this field don´t folow the work logic?

    CHECKBOX from array correct?
     
    Last edited: Feb 22, 2010
  9. moglia

    moglia New Member

    About SSL Validations

    Error: ssl_state_error_regex<br>
    ssl_locality_error_regex<br>
    ssl_organisation_error_regex<br>
    ssl_organistaion_unit_error_regex<br>
    ssl_country_error_regex<br>

    if $params['ssl'] = 0; don´t make or check any validations about SSL it´s possible? because i try insert a domain without feel this fields i can not do it.

    Possible fix need todo or another way to do it?
     
: soap

Share This Page