DPD tracking integration is region-specific. This article’s code examples focus on the DPD Germany Web Connect SOAP pattern; other DPD country services may expose different REST or SOAP APIs, authentication, shipment operations and label formats. Confirm the correct developer portal, account permissions and current service version for the shipping origin before adapting an example.
The examples show how a .NET application can isolate a DPD tracking client behind an application interface, use a typed HttpClient and configuration options, and keep authentication and XML parsing within the carrier adapter. The Germany Web Connect SOAP example uses the Parcel Life Cycle service; validate exact operations and message requirements in the DPD documentation supplied for the account.
- Keep DPD authentication separate from tracking request construction.
- Normalize the tracking number before putting it into the SOAP request.
- Use the configured DPD
HttpClientand send the requiredSOAPAction. - Parse
statusInforecords and distinguish reached/dated status from the final display label. - Normalize DPD wording into standard application states.
- Return stable no-data and error results rather than leaking carrier exceptions into the UI.
- Keep account identifiers, authentication values and customer-specific details out of public documentation.
DPD’s developer material distinguishes test and production credentials and documents regional service differences. For the Germany Web Connect SOAP offering, review the current DPD Webservices documentation. Do not reuse its endpoints or message formats for another country without confirmation.
1. Where DPD Tracking Fits in a Shipping Platform
The application should ask a tracking service for shipment status rather than knowing how DPD SOAP calls work. The carrier layer owns authentication, SOAP construction and XML parsing.
ExampleShippingApp
↓
Tracking Service
↓
IDpdTrackingClient
↓
IDpdAuthClient
↓
DPD ParcelLifeCycleService
↓
DPD XML Response
↓
TrackingInfo
↓
Standard TrackingResult
↓
UI / API
2. Create a Dedicated DPD Tracking Client
The example keeps DPD transport concerns inside DpdTrackingClient and receives its dependencies through constructor injection.
public class DpdTrackingClient : IDpdTrackingClient
{
private readonly HttpClient _httpClient;
private readonly DpdSettings _settings;
private readonly ILogger<DpdTrackingClient> _logger;
private readonly IDpdAuthClient _dpdAuthClient;
private const string LoginServiceUrl =
"https://public-ws.dpd.com/services/LoginService/V2_0/";
private const string ParcelLifeCycleServiceUrl =
"https://public-ws.dpd.com/services/ParcelLifeCycleService/V2_0";
}
3. Configure the Client with Typed Settings and Authentication
IOptions<DpdSettings> supplies typed DPD configuration and IDpdAuthClient supplies the authentication token. The tracking client therefore does not need to know how login credentials are stored or how the token is obtained.
public DpdTrackingClient(
HttpClient httpClient,
IOptions<DpdSettings> settings,
ILogger<DpdTrackingClient> logger,
IDpdAuthClient dpdAuthClient)
{
_httpClient = httpClient;
_settings = settings.Value;
_logger = logger;
_dpdAuthClient = dpdAuthClient;
}
4. Start the DPD Tracking Operation
The public method obtains the DPD authentication token, requests the tracking XML and maps the XML into TrackingInfo. The supplied implementation catches unexpected failures and returns a stable error result.
public async Task<TrackingInfo> GetTrackingAsync(
string trackingNumber,
CancellationToken cancellationToken = default)
{
try
{
string authToken =
await _dpdAuthClient.GetAuthTokenAsync();
string trackingXml =
await FetchTrackingXmlAsync(
authToken,
trackingNumber,
cancellationToken)
.ConfigureAwait(false);
return ParseTrackingResponse(
trackingXml,
trackingNumber);
}
catch (Exception ex)
{
_logger.LogError(
ex,
"DPD tracking failed for {TrackingNumber}",
trackingNumber);
return CreateErrorTrackingInfo(
"Error fetching tracking data");
}
}
5. Normalize the Tracking Number Before the SOAP Request
Normalize only according to the rules of the selected DPD service. Do not truncate a tracking identifier to a fixed length unless the account’s current API specification explicitly requires it.
string cleanTrackingNumber =
trackingNumber?.Trim().TrimEnd(',')
?? string.Empty;
if (string.IsNullOrWhiteSpace(cleanTrackingNumber))
{
throw new ArgumentException(
"A tracking number is required.",
nameof(trackingNumber));
}
6. Obtain the DPD Authentication Token Separately
Authentication is delegated to IDpdAuthClient. This keeps the tracking method focused on tracking rather than credential management or login protocol details.
string authToken =
await _dpdAuthClient.GetAuthTokenAsync();
7. Build the DPD SOAP Tracking Envelope
The supplied integration calls DPD's Parcel Life Cycle Service and uses the getTrackingData operation. The SOAP header contains the configured DelisId, the authentication token and the message language; the body contains the normalized parcel label number.
string soapEnvelope = $@"<soapenv:Envelope
xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:ns=""http://dpd.com/common/service/types/Authentication/2.0""
xmlns:ns1=""http://dpd.com/common/service/types/ParcelLifeCycleService/2.0"">
<soapenv:Header>
<ns:authentication>
<delisId>{_settings.DelisId}</delisId>
<authToken>{authToken}</authToken>
<messageLanguage>en_EN</messageLanguage>
</ns:authentication>
</soapenv:Header>
<soapenv:Body>
<ns1:getTrackingData>
<parcelLabelNumber>{cleanTrackingNumber}</parcelLabelNumber>
</ns1:getTrackingData>
</soapenv:Body>
</soapenv:Envelope>";
8. Send the SOAP Request with SOAPAction
The integration sends an HTTP POST with the XML body as text/xml and adds the exact DPD SOAPAction for getTrackingData.
using var request =
new HttpRequestMessage(
HttpMethod.Post,
ParcelLifeCycleServiceUrl)
{
Content =
new StringContent(
soapEnvelope,
Encoding.UTF8,
"text/xml")
};
request.Headers.Add(
"SOAPAction",
"http://dpd.com/common/service/types/ParcelLifeCycleService/2.0/getTrackingData");
HttpResponseMessage response =
await _httpClient.SendAsync(
request,
cancellationToken)
.ConfigureAwait(false);
9. Handle Non-Success HTTP Responses Explicitly
A completed HTTP call can still represent a carrier failure. The client reads the response body, logs the status and response, then throws an HttpRequestException when DPD returns a non-success HTTP status.
string responseBody =
await response.Content.ReadAsStringAsync()
.ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
_logger.LogError(
"DPD tracking failed: {StatusCode} - {Response}",
response.StatusCode,
responseBody);
throw new HttpRequestException(
$"DPD tracking failed: {response.StatusCode}");
}
return responseBody;
10. Parse the DPD Response with XDocument
The parser uses XDocument.Parse and finds all descendants whose local name is statusInfo. Using Name.LocalName keeps the parser independent of the namespace prefix used in the XML response.
XDocument doc =
XDocument.Parse(xml);
var allStatusInfos =
doc.Descendants()
.Where(e =>
e.Name.LocalName == "statusInfo")
.ToList();
if (allStatusInfos.Count == 0)
return CreateNoTrackingDataInfo();
11. Select the Latest Meaningful DPD Status
The example first searches for the last statusInfo where statusHasBeenReached is true and a non-empty date exists. If that is unavailable, it falls back to the last status with a date.
var reachedWithDate =
allStatusInfos
.Where(si =>
si.Elements().Any(e =>
e.Name.LocalName == "statusHasBeenReached"
&& e.Value.Equals(
"true",
StringComparison.OrdinalIgnoreCase)))
.Where(si =>
!string.IsNullOrWhiteSpace(
GetNestedContentLocal(si, "date")))
.LastOrDefault();
var statusWithDate =
reachedWithDate
?? allStatusInfos.LastOrDefault(
si =>
!string.IsNullOrWhiteSpace(
GetNestedContentLocal(si, "date")));
12. Use the Final Status Label for Display
The code then uses the final statusInfo element overall for the display label, while the selected dated status supplies the location and date used for shipment details.
var displayStatusInfo =
allStatusInfos.Last();
string rawLabel =
GetNestedContentLocal(
displayStatusInfo,
"label");
string location =
statusWithDate != null
? GetNestedContentLocal(
statusWithDate,
"location")
: string.Empty;
string dateStr =
statusWithDate != null
? GetNestedContentLocal(
statusWithDate,
"date")
: string.Empty;
13. Read Nested XML Content Safely
DPD values are nested under a content child. The helper reads the requested child by local name and then returns the nested content value.
private static string GetNestedContentLocal(
XElement parent,
string tagName)
{
var element =
parent.Elements()
.FirstOrDefault(
e => e.Name.LocalName == tagName);
if (element == null)
return string.Empty;
var contentElement =
element.Elements()
.FirstOrDefault(
e => e.Name.LocalName == "content");
return contentElement?.Value.Trim()
?? string.Empty;
}
14. Handle No-Tracking Responses Explicitly
The example checks for labels such as no tracking, not found, no information, unavailable and no data. These responses become a dedicated no-tracking state rather than a misleading Pending status.
private bool IsNoTrackingDataMessage(
string statusMessage)
{
if (string.IsNullOrWhiteSpace(statusMessage))
return true;
string lower =
statusMessage.ToLowerInvariant();
return lower.Contains("no tracking")
|| lower.Contains("not found")
|| lower.Contains("no information")
|| lower.Contains("unavailable")
|| lower.Contains("no data");
}
private TrackingInfo CreateNoTrackingDataInfo()
{
return new TrackingInfo
{
Status = "No Tracking Data",
DisplayStatus = "No Tracking Data",
EstDelivery = "—",
LastUpdate = "—"
};
}
15. Build a Rich Status with Date and Location
The example parser preserves the raw DPD label and adds a formatted date and location when those values are available.
string richDetail = rawLabel;
if (!string.IsNullOrWhiteSpace(dateStr))
{
if (DateHelper.TryParseDate(
dateStr,
"dd/MM/yyyy, HH:mm",
out DateTime dt))
{
richDetail +=
$" on {dt:dd MMM yyyy HH:mm}";
}
else
{
richDetail +=
$" on {dateStr}";
}
}
if (!string.IsNullOrWhiteSpace(location))
richDetail += $" at {location}";
16. Normalize DPD Statuses into Standard States
The example maps carrier wording into application states such as Delivered, In Transit and Pending; map every status required by the selected service.
| Application state | Example DPD wording |
|---|---|
| Delivered | A message containing “delivered” |
| In transit | A configured in-transit phrase for the selected service |
| Pending or unknown | Unmapped wording retained for review |
17. Use Case-Insensitive Substring Matching
The status mapper deliberately uses substring matching. This lets descriptive carrier messages still match the application's standard states without requiring an exact label.
private string NormalizeStatus(
string rawStatus)
{
if (string.IsNullOrWhiteSpace(rawStatus))
return "Pending";
string lower =
rawStatus.ToLowerInvariant();
if (lower.Contains("delivered"))
return "Delivered";
if (lower.Contains("out for delivery"))
return "In Transit";
if (lower.Contains("in transit"))
return "In Transit";
if (lower.Contains("delivery centre"))
return "In Transit";
if (lower.Contains("handed to dpd")
|| lower.Contains("parcel handed to dpd"))
return "In Transit";
if (lower.Contains("sending depot"))
return "In Transit";
return "Pending";
}
18. Present Carrier Status Without an Invented Percentage
DPD event labels describe carrier-reported milestones. They do not define a universal percentage complete. Show the normalized status and documented event time; add a progress indicator only if the selected service provides milestones that your application can map reliably.
19. Keep Delivered Time Separate from an Estimate
A delivery event timestamp records when the carrier reports delivery. It is not an estimated delivery date. Keep those values in separate fields, and populate an estimate only when the selected DPD service returns a documented estimate.
string? deliveredAt = null;
if (normalizedStatus.Equals(
"Delivered",
StringComparison.OrdinalIgnoreCase))
{
deliveredAt = lastUpdate;
}
// Store deliveredAt separately from any carrier-provided estimate.
20. Format DPD Dates in One Place
The carrier date format handled by The example is dd/MM/yyyy, HH:mm. The helper returns a consistent display format and falls back to the original value when parsing fails.
private string FormatLastUpdate(
string dateStr)
{
if (string.IsNullOrWhiteSpace(dateStr))
return "—";
if (DateHelper.TryParseDate(
dateStr,
"dd/MM/yyyy, HH:mm",
out DateTime dt))
{
return dt.ToString(
"dd MMM yyyy, HH:mm");
}
return dateStr;
}
21. Return the TrackingInfo Result
After parsing, an application can return normalized status, display text, a separately stored delivered timestamp, last update and selected diagnostic fields in RawData.
return new TrackingInfo
{
Status = normalizedStatus,
DisplayStatus = richDetail,
DeliveredAt = deliveredAt,
LastUpdate = lastUpdate,
RawData = new
{
RawLabel = rawLabel,
Location = location,
RawDate = dateStr
}
};
22. Return Stable Error Results
Remote failures are converted into a predictable tracking result so the application does not have to expose carrier exceptions directly to the user interface.
private TrackingInfo CreateErrorTrackingInfo(
string errorMessage)
{
return new TrackingInfo
{
Status = "Exception",
DisplayStatus = "Error",
EstDelivery = "—",
LastUpdate = errorMessage
};
}
23. Keep Authentication, SOAP and Parsing Separate
An illustrative design can separate responsibilities: IDpdAuthClient provides authentication, DpdTrackingClient builds and sends the DPD request, and ParseTrackingResponse interprets the carrier XML.
IDpdAuthClient
↓
Authentication Token
↓
DpdTrackingClient
↓
SOAP Request
↓
DPD ParcelLifeCycleService
↓
XML Response
↓
ParseTrackingResponse(trackingXml, trackingNumber)
↓
TrackingInfo
24. Use DPD as One Carrier in a Multi-Carrier Platform
DPD should remain one implementation in a broader tracking architecture. UPS, DHL, DPD and Asendia can each retain their carrier-specific authentication and response parsing while the application works with a common tracking workflow.
ITrackingClient
│
├── UPS Tracking Client
├── DHL Tracking Client
├── DPD Tracking Client
└── Asendia Tracking Client
25. Protect DPD Credentials and Customer Information
A deployment may require account-specific settings such as DelisId and an authentication token. This article intentionally does not reproduce customer identifiers, credentials, account values or other environment-specific secrets. Those values should remain in secure application configuration and authentication components.
The same rule applies to logs. Structured logging should carry enough information to diagnose failures without unnecessarily storing credentials or sensitive shipment data.
26. Test the DPD Integration at Multiple Levels
- Validate tracking-number normalization against the selected DPD service requirements.
- Test authentication independently from tracking.
- Test SOAP request generation with safe test settings.
- Test unsuccessful HTTP responses.
- Test XML with no
statusInfoelements. - Test reached-status selection and fallback-to-dated-status behavior.
- Test every known status phrase plus unknown wording.
- Test DPD date parsing and fallback behavior.
- Test no-data and error-result mapping.
27. Measure Authentication, SOAP and Parsing Separately
A slow tracking screen can have several causes. Measure authentication, the DPD HTTP request, XML parsing, status normalization and application mapping separately rather than treating the whole tracking operation as one black box.
Authentication: measure separately
DPD SOAP request: measure separately
XML parsing: measure separately
Status normalization: measure separately
Application mapping: measure separately
28. The Complete DPD Tracking Flow
The Germany Web Connect example can be summarized as the following sequence.
1. Receive tracking number
↓
2. Obtain DPD authentication token
↓
3. Trim and normalize tracking number
↓
4. Validate the tracking number against the selected service requirements
↓
5. Build DPD SOAP envelope
↓
6. POST to ParcelLifeCycleService
↓
7. Add SOAPAction for getTrackingData
↓
8. Validate HTTP response
↓
9. Parse XML with XDocument
↓
10. Locate statusInfo records
↓
11. Select latest reached/dated status
↓
12. Read final display label
↓
13. Normalize DPD status
↓
14. Present carrier status
↓
15. Format last update
↓
16. Return TrackingInfo
↓
17. Map to the application's standard tracking result
29. DPD Tracking API Integration Checklist
- Is DPD tracking isolated behind
IDpdTrackingClient? - Is authentication handled by
IDpdAuthClient? - Are DPD settings provided through typed configuration?
- Is the tracking number normalized before the SOAP request?
- Does tracking-number validation follow the selected DPD service requirements?
- Is the correct SOAPAction used?
- Are HTTP failures handled explicitly?
- Are
statusInforecords parsed by local name? - Are reached and dated statuses selected correctly?
- Are DPD labels normalized into application-level states?
- Are no-data and exception results handled separately?
- Are account identifiers and secrets excluded from public source?
- Can the application reuse the same tracking workflow for UPS, DHL, DPD and Asendia?
30. Conclusion
A production DPD Tracking API integration in C# requires careful handling of authentication, SOAP request construction, tracking-number normalization, XML parsing, status selection, date formatting and application-level failures.
A clean carrier boundary keeps DPD-specific authentication, HTTP or SOAP behavior and response mapping inside an adapter, then returns a stable result to the application layer. The protocol and adapter contract should match the DPD service available for the account.
That separation also makes DPD easier to maintain alongside UPS, DHL and Asendia integrations in an enterprise shipping platform.
When a DPD interface needs to connect with order ownership, shipment creation and exception handling, review the DPD integration service and ERP integration approach. The enterprise shipping case study provides context for multi-carrier workflows.