Not logged in - Login
View History

Shipment Service PHP Example

It is NOT recommended to use this minimal example.

Please check the DIS library for an extended example and best practices.

//The header is filled with the data you got from the authentication service
$soapHeaderBody = array(
  'delisId' => <your delisID> 
  ,'authToken' => <your token>
  ,'messageLanguage' => 'en_US'
);

$header = new SOAPHeader('http://dpd.com/common/service/types/Authentication/2.0', 'authentication', $soapHeaderBody, false);
  
$client = new SoapClient('https://public-dis-stage.dpd.nl/Services/ShipmentService.svc?wsdl');
  
$soapHeader = $header;
$client->__setSoapHeaders($soapHeader);
  
$result = $client->storeOrders(array(
  'printOptions' => array(
    'printerLanguage' => 'PDF'
    ,'paperFormat' => 'A6'
  )
  ,'order' => array(
    'generalShipmentData' => array(
        'sendingDepot' => $result->return->depot
        ,'product' => 'CL'
        ,'sender' => array(
            'name1' => 'ACME'
            ,'street' => 'Egide Walschaertsstraat'
            ,'houseNo' => '20'
            ,'country' => 'BE'
            ,'zipCode' => '2800'
            ,'city' => 'Mechelen'
        )
        ,'recipient' => array(
            'name1' => 'Wiley Coyote'
            ,'name2' => 'RR Catchers NV'
            ,'street' => 'Zandstraat'
            ,'houseNo' => '300A'
            ,'country' => 'BE'
            ,'zipCode' => '1000' // No spaces in zipCode!
            ,'city' => 'Brussel'
        )
    )
    ,'parcels' => array(
      'weight' => 200
    )
    ,'productAndServiceData' => array(
      'orderType' => 'consignment'
    )
  )
  ));
  
  print_r($result);

This example should return something like:

stdClass Object
(
    [orderResult] => stdClass Object
        (
            [parcellabelsPDF] => <binairy PDF String>
            [shipmentResponses] => stdClass Object
                (
                    [identificationNumber] => 
                    [mpsId] => MPS0990000000056320160404
                    [parcelInformation] => stdClass Object
                        (
                            [parcelLabelNumber] => 09900000000563
                        )

                )

        )

)

To get the PDF to display:


header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="my.pdf"');
echo $result->orderResult->parcellabelsPDF;

This should propose a download of the new label.

Note: if you reader asks you to save the label when you want to close it, or it won't even open due to a 'decoding' problem, open the pdf in your favorite text editor and verify that your site isn't printed before the pdf data. In the image below the real start of the PDF document is selected.