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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
| <?php
//Initialisation des valeurs
$civility = 'M';
$surname = 'André';
$firstname = 'DESFEYSSE';
$adress = '69 rue de la république';
$adress2 = 'a gauche au fond de l impasse';
$city = 'Alix';
$countrycode = 'FR';
$countryname = 'FRANCE';
$completename = 'André DESFEYSSE';
$email = 'Test@gmail.com';
$mobilephonenumber = '0696911001';
$phonenumber = '0449691100';
$zipcode = '69210';
$commandeNo = '000000000000001';
$articleNo ='24';
$productcode = '16';
//Generate a date at ISO 8601 format 2004-02-12T15:19:21+00:00
$shippingdate = date('c');
$weight = '2';
$numberofparcel = '1';
$height = '10';
$length = '20';
$width = '20';
// WEBSERVICE'S WSDL ADDRESS
$wsdl = "https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl";
//CALLING SOAP CLIENT CONSTRUCTOR FUNCTION
$client_ch = new soapClient($wsdl);
$client_ch->soap_defencoding = 'UTF-8';
$client_ch->decode_utf8 = false;
// LISTING OF NEEDED PARAMETERS FOR THE SOAP CALL IN AN ARRAY
$params = array(
//STRUCTURE HEADER VALUE
'headerValue' => array(
'accountNumber' => '666666666',
'idEmit' => 'CHFR',
'identWebPro' => '',
'subAccount' => '',
),
//STRUCTURE SHIPPERVALUE
'shipperValue' => array(
'shipperAdress1' => $adress,
'shipperAdress2' => $adress2,
'shipperCity' => $city,
'shipperCivility' => $civility,
'shipperContactName' => $completename,
'shipperCountry' => $countrycode,
'shipperCountryName' => $countryname,
'shipperEmail' => $email,
'shipperMobilePhone' => $mobilephonenumber,
'shipperName' => $surname,
'shipperName2' => $firstname,
'shipperPhone' => $phonenumber,
'shipperPreAlert' => 0,
'shipperZipCode' => $zipcode,
),
//STRUCTURE CUSTOMERVALUE
'customerValue' => array(
'customerAdress1' =>'40 RUE JEAN JAURES',
'customerAdress2' => '',
'customerCity' =>'BAGNOLET',
'customerCivility' =>'M',
'customerContactName' =>'Jean MARTIN',
'customerCountry' =>'FR',
'customerCountryName' =>'FRANCE',
'customerEmail' =>'client@mail.fr',
'customerMobilePhone' =>'0611223344',
'customerName' =>'ETABLISSEMENTS ET FILS',
'customerName2' => '',
'customerPhone' =>'0133333333',
'customerPreAlert' => 0,
'customerZipCode' =>'93170',
'printAsSender' =>'N',
),
//STRUCTURE RECIPIENTVALUE
'recipientValue' => array(
'recipientAdress1' => '3 Route des Pierres noires',
'recipientAdress2' => '',
'recipientCity' => 'Eugrèzie la Nevarre',
'recipientContactName' => 'BRIBES DINFO',
'recipientCountry' => 'FR',
'recipientCountryName' => 'FRANCE',
'recipientEmail' => 'test@gmail.com',
'recipientMobilePhone' => '06666666',
'recipientName' => 'BRIBES DINFO',
'recipientName2' => '',
'recipientPhone' => '044444444',
'recipientPreAlert' => 0,
'recipientZipCode' => '06920',
//'recipientCivility' => 'M',
),
//STRUCTURE REFVALUE
'refValue' => array (
'customerSkybillNumber' => '123456789',
'PCardTransactionNumber' =>'',
'recipientRef' => $articleNo,
'shipperRef' => $commandeNo,
),
//STRUCTURE SKYBILLVALUE
'skybillValue' => array(
'bulkNumber' => 2,
'codCurrency' => 'EUR',
'codValue' => 0,
'customsCurrency' =>'EUR',
'customsValue' => 0,
'evtCode' => 'DC',
'insuredCurrency' => 'EUR',
'insuredValue' => 0,
'masterSkybillNumber' => '?',
'objectType' => 'MAR',
'portCurrency' =>'EUR',
'portValue' => 0,
'productCode' => $productcode,
'service' => '0',
'shipDate' => $shippingdate,
'shipHour' => '10',
'skybillRank' => 1,
'weight' => $weight,
'weightUnit' => 'KGM',
'height' => $height,
'length' => $length,
'width' => $width,
),
//STRUCTURE SKYBILLPARAMSVALUE
'skybillParamsValue' => array(
'mode' => 'PDF',
),
//OTHERS
'password' => 'XXXXXXX',
'modeRetour' => '2',
'numberOfParcel' => $numberofparcel,
'version' => '2.0',
'multiparcel' => 'Y',
);
// YOU CAN FIND PARAMETERS YOU NEED IN HERE
//var_dump($client_ch->__getFunctions());
//var_dump($client_ch->__getTypes());
try {
$results = $client_ch->shippingMultiParcelWithReservation($params);
//var_dump($results);
}
catch (SoapFault $soapFault) {
var_dump($soapFault);
echo "Request :<br>", htmlentities($client_ch->__getLastRequest()), "<br>";
echo "Response :<br>", htmlentities($client_ch->__getLastResponse()), "<br>";
}
if( isset($results)){
$reservationNumber = $results->return->reservationNumber;
echo $reservationNumber;
try {
$results = $client_ch->getReservedSkybill($reservationNumber);
var_dump($results);
}
catch (SoapFault $soapFault) {
var_dump($soapFault);
echo "Request :<br>", htmlentities($client_ch->__getLastRequest()), "<br>";
echo "Response :<br>", htmlentities($client_ch->__getLastResponse()), "<br>";
}
}
?> |
Partager