Not logged in - Login
View History

Shipment Service CSharp Example

Add the web reference to the project as described in Login Service. The url to the web service: https://public-dis-stage.dpd.nl/Services/ShipmentService.svc?wsdl First call the login service to get a token.

try 
{
            ShipmentService.ShipmentService shipmentService = new ShipmentService.ShipmentService();

            // add the parcels to the shipment data
            shipmentServiceData data = new shipmentServiceData();
            data.generalShipmentData = new generalShipmentData();
            data.generalShipmentData.sendingDepot =  "0522";
            data.generalShipmentData.recipient = new address()
            {
                name1 = "DPD nederland",
                street = "street",
                country = "NL",
                zipCode = "5684PK",
                city = "BEST",
                customerNumber = "550547"
            };
            data.generalShipmentData.sender = new address() 
            {
                name1 = "Test Shop",
                street = "Locht 44 a5",
                country = "NL",
                zipCode = "6466GW",
                email = "info@dpd.nl",
                city = "Kerkrade",
                comment = "commentaar"
            };
            data.productAndServiceData = new productAndServiceData() 
            {                 
                orderType = productAndServiceDataOrderType.consignment 
            };
 
            // parcels for this order
            List<parcel> parcelList = new List<parcel>();
 
            // return parcel example
            parcel returnParcel = new parcel()
            {
                returns = true
            };
            parcelList.Add(returnParcel);
 
            // volume parcel
            parcel volumeParcel = new parcel()
            {
                volume = 60020020
            };
            parcelList.Add(volumeParcel);
 
            // add parcels
            data.parcels = parcelList.ToArray();
 
            // add shipment data
            List<shipmentServiceData> dataList = new List<shipmentServiceData>();
            dataList.Add(data);
 
            // add print options
            printOptions print = new printOptions();
            print.paperFormat = new printOptionsPaperFormat();
            print.paperFormat = printOptionsPaperFormat.A6;
 
            // orders to send
            storeOrders orders = new storeOrders();
            orders.printOptions = print;
            orders.order = dataList.ToArray();
                        
            // add authentication
            authentication auth = new authentication() 
            { 
                delisId = delisId, 
                authToken = authToken 
            };
 
            // create respons object
            storeOrdersResponse shipmentResponse = new storeOrdersResponse();
            
            // do request
            shipmentService.authenticationValue = auth;
            shipmentResponse = shipmentService.storeOrders(orders);
 
            // get the PDF label from the response
            string PDFlabel = Convert.ToBase64String(shipmentResponse.orderResult.parcellabelsPDF);
}
catch (Exception e) 
{

             // handle exception here!

}