2009-07-09 06:48:47 +00:00

77 lines
3.7 KiB
PHP

<?php
function infogreffeProduits($siren, $type){
$req = '<demande>'.
'<emetteur>'.
'<code_abonne>'.INFOGREFFE_WS_USER.'</code_abonne>'.//85009006
'<mot_passe>'.INFOGREFFE_WS_PASS.'</mot_passe>'.//
'<reference_client>'.INFOGREFFE_WS_REF.'</reference_client>'.
'<code_requete>'.
'<type_profil>A</type_profil>'.
'<origine_emetteur>IC</origine_emetteur>'.
'<nature_requete>C</nature_requete>'.
'<type_document>'.$type.'</type_document>'.// KB=Kbis, HQ=Histo, ST=Statut, AC=Acte, LE=Liste étab
'<type_requete>S</type_requete>'.
'<media>WS</media>'.
'<mode_diffusion>'.
'<mode type="T"/>'.
'</mode_diffusion>'.
'</code_requete>'.
'</emetteur>'.
'<commande>'.
'<num_siren>'.$siren.'</num_siren>'.
'</commande></demande>';
$req = utf8_encode($req);
$client2 = new SoapClient(null, array(
'location' => INFOGREFFE_WS_URL,
'uri' => INFOGREFFE_WS_URI,
'soap_version' => SOAP_1_1,
'trace' => 1,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
));
try {
$O = $client2->getProduitsWebServicesXML($req);
$xml = implode('', (array)$O);
}catch (SoapFault $soapFault) {
$success = false;
$response = $client2->__getLastResponse();
$response = str_replace("<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><SOAP-ENV:Body><ns0:getProduitsWebServicesXMLResponse xmlns:ns0='urn:local' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><return xsi:type='xsd:string'>",'', $response);
$xml = str_replace('</return></ns0:getProduitsWebServicesXMLResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>','', $response);
}
/*
$post = '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://webservices.infogreffe.fr/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getProduitsWebServicesXML><param0 xsi:type="xsd:string">'.$req.'</param0></ns1:getProduitsWebServicesXML></SOAP-ENV:Body></SOAP-ENV:Envelope>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_COOKIEFILE,TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$output = curl_exec($ch);
$xml = str_replace("<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><SOAP-ENV:Body><ns0:getProduitsWebServicesXMLResponse xmlns:ns0='urn:local' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><return xsi:type='xsd:string'>",'', $output);
$xml = str_replace('</return></ns0:getProduitsWebServicesXMLResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>','', $xml);
*/
return $xml;
}
function getKbis($siren){
global $client;
//ini_set('default_socket_timeout', 120); //timeout 2 min
$return = FALSE;
try {
$O = $client->getKbis($siren, 1,0);
$kbis = $O['result'];
$return = $kbis['Url'];
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$_SESSION['tabInfo']);
}
return $return;
}