$identification
|-> $application
|-> $certificate
*/
//login
$identification = array (
'utilisateur' => 'username', //User
'motDePasse' => 'password' //Password
);
/*Application*/
//Certificate Information
//Only one value is mandatory
$certificate = array (
'refTBS' => '0123456789', //TBS reference (10 numbers)
'refCA' => '', //CA Reference
'refClient' => '', //Your reference
'nrSerie' => '', //Serial Number
);
//Main order information
/*
typeDemande requires specific values to produce the desired output:
0: Complete status
1: State / certificate / validity date
2: State
typeReponse changes the certificate output:
'x509': base64 pem certificate
'pkcs7': PKCS#7 (.p7b) certificate
'chaine': certificate chain (base64 PEM)
*/
$application = array(
'refDemande' => '',
'certificat' => $certificate,
'typeDemande' => '0', //status type
'typeReponse' => 'chaine' //response type
);
//Making the final array
$status = array (
'identification' => $identification,
'demande' => $application
);
/** XML-RPC **/
//vars
$RpcType = array (
'dureeVie' => 'int',
'nbLicence' => 'int',
'keySize' => 'int',
'typeDemande' => 'int'
);
$rpcValues = array();
//Functions
//Converts our arrays into RPC-ready data, uses recursivity for structures.
function tab2rpc($tab) {
$tabReturn = false;
if ($tab && is_array($tab)) {
$tabReturn = array();
while (list($key,$val) = each($tab)) {
if ($val && is_array($val)) {
$tabReturn[$key]=new xmlrpcval(tab2rpc($val), "struct");
}else{
if (isset($RpcType[$key])) $type = $RpcType[$key];
else $type = "string";
$tabReturn[$key]=new xmlrpcval($val, $type);
}
}
}
return $tabReturn;
}
//Creating the value array
$rpcValues = tab2rpc($status);
//Creating the message
$message = new xmlrpcmsg('statut'); //This value varies depending on the type of operation
$message->addParam(new xmlrpcval($rpcValues,"struct"));
//Client configuration
$client = new xmlrpc_client($appli, $serveur, $port);
$client->setSSLVerifyPeer(false);
$client->setSSLVerifyHost(false);
$client->setDebug(2);
//Sending the request and getting the response
$reponse = $client->send($message,0,$transport);
$valeur = $reponse->value();
//Trace display
if(!$reponse->faultCode()) {
$msig = php_xmlrpc_decode($valeur);
echo "".nl2br(print_r($msig,true))."
";
echo '
'.$l.' | '.$table['codeReponse'].' | '.$table['messageReponse'].' |
Code: ".$reponse->faultCode()."
Message : ".$reponse->faultString()."
".print_r($reponse, true)."