1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| $xml_data = '<?xml version="1.0" encoding="utf-8"?>
<commande>
<commandeType>O</commandeType>
<transId>123456</transId>
<promotion>NEWYEAR</promotion>
<client>
<city>PARIS</city>
<true>N</true>
</client>
</commande>';
//$url_ws = 'https://webserviceexterne.com/ws/commande/TOTO?appId=qscvhu&pwd=1598753&xml=';
$url_ws = 'https://webserviceexterne.com/ws/commande/TOTO?appId=qscvhu&pwd=1598753';
/* supp
$headers = array(
'Content-Type: text/xml;charset=utf-8;xml version=1.0'
); //NEW!!!
*/
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url_ws);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($curl,CURLOPT_POSTFIELDS, "xmlRequest=" . $xml_data);
//curl_setopt($curl,$curl,CURLOPT_POSTFIELDS, $xml_data); //NEW!!!
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array('xml' => $xml_data)));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // recevoir le résultat du transfert
//curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
//curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); //NEW!!!
$response = curl_exec($curl);
if(curl_errno($curl))
{
echo 'Erreur Curl : ' . curl_error($curl);
}
else
{
$info = curl_getinfo($curl);
print_r($info);
}
print_r($response);
curl_close($curl); |
Partager