Implementing DHL XML Services
Implementing DHL XML Services
Status Issued
Date 03-11-2014
Page 1 of 21
Implementing DHL XML Services
Document Control
Revision history:
Version Release Date Comments
Page 2 of 21
Implementing DHL XML Services
CONTENT
1. INTRODUCTION ........................................................................................................... 4
1.1 DHL XML SERVICES ....................................................................................................... 4
1.2 DHL XML SERVICES TOOLKIT ........................................................................................... 5
2. IMPLEMENTING DHL XML SERVICES .......................................................................... 6
2.1 RECOMMENDED PROCESS FLOWS ...................................................................................... 6
3. SENDING & RECEIVING XML REQUESTS ..................................................................... 7
4. CAPABILITY AND QUOTE SERVICE ............................................................................. 8
4.1 ACCOUNT SPECIFIC RATES: ............................................................................................... 8
4.2 NETWORK TYPE FOR CAPABILITY & QUOTE REQUEST: .............................................................. 8
4.3 SPECIFYING DUTIABLE OR NON-DUTIABLE ............................................................................ 9
4.4 PRODUCT RESTRICTIONS IN CAPABILITY RESPONSE .................................................................. 9
4.5 QUOTE REQUESTS .......................................................................................................... 9
5. SHIPMENT VALIDATION SERVICE ............................................................................. 10
5.1 LICENSE PLATE ENABLED ................................................................................................ 10
5.2 USING THE DUTIES & TAXES PAID SERVICE ......................................................................... 10
5.3 REQUESTING ADDITIONAL INSURANCE............................................................................... 10
5.4 SHIPMENT REFERENCE ................................................................................................... 11
6. BOOK PICKUP ............................................................................................................ 11
6.1 BOOKING PICKUP REQUESTS ........................................................................................... 11
7. RECEIVING LABEL IMAGES IN THE SHIPMENT VALIDATE RESPONSE ..................... 12
7.1 REQUEST .................................................................................................................... 12
7.2 RESPONSE .................................................................................................................. 17
8. USING THE LABEL UTILITY ........................................................................................ 17
9. APPENDIX A – SAMPLE REQUEST INCLUDING LABEL ELEMENT ............................. 18
10. APPENDIX B – SAMPLE RESPONSE INCLUDING LABEL ELEMENTS .......................... 19
11. APPENDIX C – TEST ENVIRONMENT ACCESS ........................................................... 21
Page 3 of 21
Implementing DHL XML Services
1. Introduction
DHL offers an XML based online integration platform that provides Product Availability,
Transit time and Rating, Shipment Booking, Courier Pickup Booking and Tracking services for
DHL Express customers globally from over 140 countries.
DHL XML Services can help DHL customers and vendor partners in the following ways:
Use own shipping and warehouse management systems to access the complete set of
DHL shipping services
Provide DHL capabilities from their internal shipping sites, Shopping carts and
Commerce web sites
No DHL hardware or software deployed on their site
A standard (XML) and secured (HTTPS and User Authentication) platform to integrate
with DHL and the customer controlling the implementation timelines
Capability & Quote – Provides list of available product and services for given shipment
criteria along with Booking cut-off, Pickup cut-off and Transit times, Provides total cost
along with breakdown of charges for requested product and certain service
combinations
Shipment Validation -Validates shipment data and return Waybill, License Plate and
data for label printing
PDF Label Image utility* – Generates DHL compliant label image using the XML
response from Shipment Validation
Pickup Request – Can request a courier collection from fixed and ad-hoc addresses
Pickup Cancellation – Cancel Pickup Requests made via the Pickup Request service.
Tracking - Obtain shipment details and event visibility filtered by Waybill, License Plate,
or Reference Number and Account Number
Routing - Validates the origin and destination city and postcodes.
(Note: that these validations are now better performed in Capability Service and hence
we recommend users to stop using Routing Service and instead use Capability Service)
Page 4 of 21
Implementing DHL XML Services
http://xmlpitest-ea.dhl.com/toolkit/Toolkit.zip
It contains a detailed description for the format of the Request and Response XML messages for
each service. Sample request and response XML messages that help understand the structure of
the request and response messages are also included.
These messages also help to understand the conditions/data values that might result in an error
response from DHL XML Services server.
The toolkit contains a sample Jasper report that assists in the transformation of a Shipment
Validation Response XML message into the Global Label and Archive Label in A4 -PDF format.
1. DHLClient: To send an XML request message to the DHL XML Services application. This
can be directly integrated with the client application or it can be used to understand the
method to establish a connection with DHL XML Services.
2. generateAWB: This is used to transform the Shipment Validate XML Response into the
Global Label and Archive Label in an A4 -PDF format.
3. generateLabel: This is the label utility that allows the user to generate Global Label or
Archive Label or both labels in the required supported GLSv3 format with the Shipment
Validation XML response.
Historically, DHL XML Services was available in three Regions with the XML Request messages
slightly customized for each Region, despite all three Regions being supported by a central
application and accessible by the same web server address.
However, there is now an additional Global Schema which is recommended for use, as the
same request can be used across all three regions below.
AP-EM Region -Supports countries in Asia, Africa, Australia and Pacific.
EU Region -Supports countries in Europe.
AM Region -Supports USA and other countries in North and South Americas.
If the regional requests are used, it is important that the appropriate Regional XSD and
documentation is used based on the country of origin.
A Toolkit PDF document (Toolkit_v4x.pdf) is included in the Zip file download and explains
how to configure the above Java tools as well as detailing how the toolkit is structured once
fully extracted
Page 5 of 21
Implementing DHL XML Services
Page 6 of 21
Implementing DHL XML Services
The provided DHLClient.class (with DHLClient.cmd) can execute this process on behalf of the
calling program, using input parameters to identify the location of the XML request message,
the server URL and the path that the response message should be placed in.
It is suggested that any error responses be dealt with by the customer's application as they
occur, and that the response message folder be kept "clean". Having a large number of error
responses in this directory can slow down the label generation process (see below).
Alternatively some customers choose to implement this simple protocol natively in their server-
side scripting language (e.g. php), rather than using the supplied java code.
There are many ways to implement XML requests and responses with PHP. Any method you
prefer can be used which can handle communications with an XML server.
For example PEAR has many pre built scripts to handle such requests. CURL can also be used to
perform these tasks. Or just use the built in PHP functions that are part of the native language.
Page 7 of 21
Implementing DHL XML Services
Capability (and Quote) service is an essential part of the shipment creation process.
The Capability and Quote service provides a list of available products and services for the given
shipment criteria along with Booking cut-off, Pickup cut-off and Transit times.
It provides the total cost along with a breakdown of charges for required product and certain
service combinations.
It can be a useful way of verifying the address is suitable for the DHL network to assist with
routing and delivery.
Therefore you could use it during address capture routines to validate an address.
Using the Capability and Quote response you can offer the user valid products to use for the
shipment.
The response also includes all the relevant codes to use in the shipment validation request when
creating the label.
Also if you wish to use timed products you must use the capability and quote service to verify
timed products are available to the destination as they are only valid to certain postcode areas.
Example:
<NetworkTypeCode>AL</NetworkTypeCode>
If this element is not included in the request, the response defaults to TD products only.
Page 8 of 21
Implementing DHL XML Services
<IsDutiable>N</IsDutiable>
Shipments outside the EU should specify Y if the contents are dutiable and require customs
clearance or N if the contents are documents only and do not require customs clearance.
The products returned in the capability response are determined based on this value.
If Y is returned it means the product can only be used if there is a pre-arranged agreement in
place with DHL. e.g. ‘Medical Express’ or ‘Express Easy’
Therefore, you must only use products that have a value of N for POfferedCustAgreement
unless otherwise agreed with your DHL Account Manager.
The same concept applies to Special Services with the SOfferedCustAgreement flag.
Page 9 of 21
Implementing DHL XML Services
The Shipment Validation service is used to prepare the shipment. This service creates a Waybill
number and license plate for each piece in shipment on successful completion of the shipment
validation request. This waybill number and license plate number are sent back to the client that
can be used by client for tracking the shipment.
It also has a label request service to obtain pre-rendered label images in various formats. (For
more information on this, service, please see Section 7 ‘Receiving label images in the
Shipment Validate Response’)
This will ensure that individual License Plate identifiers are returned for each piece in the
shipment.
<SpecialService>
<SpecialServiceType>II</SpecialServiceType>
<ChargeValue>2000.00</ChargeValue>
<CurrencyCode>GBP</CurrencyCode>
</SpecialService>
The <ChargeValue> and <CurrencyCode> should reflect the declared value of the shipment. If
the shipment is dutiable, then these values should match the <DeclaredValue> and
<CurrencyCode> values in the dutiable section of the message, otherwise this will return a
validation error.
Also, <InsuredAmount> should be included after the <Contents> element in the request.
Page 10 of 21
Implementing DHL XML Services
<Reference>
<ReferenceID>ABC-12345</ReferenceID>
</Reference>
6. Book Pickup
Page 11 of 21
Implementing DHL XML Services
Customers are now able to request to receive a Base64 encoded label to be returned in the
Shipment Validate Response message
7.1 Request
Include the following in the request XML document.
7.1.1 LabelImageFormat
Example:
<LabelImageFormat>PDF</LabelImageFormat>
<LabelImageFormat> Element
7.1.2 RequestArchiveDoc
Example:
<RequestArchiveDoc>Y</RequestArchiveDoc>
<RequestArchiveDoc> Element
Page 12 of 21
Implementing DHL XML Services
7.1.3 CustData
The <CustData> element is used to print additional ‘Customer Specific’ information on the labels. This additional text can
only be printed on the 8x4 format label using the following templates:
8X4_CI_PDF
8X4_CI_thermal
Example:
<CustData> Customer information to be printed on the label</CustData>
<Resolution> element
<xsd:simpleType name="CustData">
<xsd:annotation>
<xsd:documentation>CustData</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1" />
<xsd:maxLength value="100" />
</xsd:restriction>
</xsd:simpleType>
7.1.4 Label
<Label> defines the required label template, customer’s logo image plus image format,
and DPI resolution.
Page 13 of 21
Implementing DHL XML Services
7.1.4.1 LabelTemplate
Example:
<LabelTemplate>8X4_A4_PDF</LabelTemplate>
<LabelTemplate> Element
<xsd:simpleType name="LabelTemplate">
<xsd:annotation>
<xsd:documentation>LabelTemplate</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="8X4_A4_PDF" />
<xsd:enumeration value="8X4_thermal" />
<xsd:enumeration value="8X4_A4_TC_PDF" />
<xsd:enumeration value="8X4_CI_PDF" />
<xsd:enumeration value="8X4_CI_thermal" />
<xsd:enumeration value="6X4_A4_PDF" />
<xsd:enumeration value="6X4_thermal" />
</xsd:restriction>
</xsd:simpleType>
If an incorrect Label Image Format type and label template combination is used in
Shipment Validate Request, then the below defaults will be used
LabelImageFormat
PDF EPL2 ZPL2
8X4_A4_PDF 8X4_CI_thermal 8X4_CI_thermal
8X4_A4_TC_PDF 8X4_thermal 8X4_thermal
LabelTemplate
8X4_CI_PDF 6X4_thermal
6X4_A4_PDF
7.1.4.2 Logo
<Logo> determines DHL logo to be printed in thermal label printout. This can be set to
‘N’ only if printing on labels with the DHL logo pre-printed already.
Example:
<Logo>Y</Logo>
<Logo> Element
<xsd:element name="Logo" type="YesNo" minOccurs="0"/>
Page 14 of 21
Implementing DHL XML Services
7.1.4.3 CustomerLogo
<CustomerLogo> consists of shipper company logo image in base64 and its image size
format to be printed in Transport label.
<xsd:complexType name="CustomerLogo">
<xsd:annotation>
<xsd:documentation>CustomerLogo</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="LogoImage" type="LogoImage" />
<xsd:element name="LogoImageFormat" type="LogoImageFormat" />
</xsd:sequence>
</xsd:complexType>
LogoImage
<LogoImage> can be used to include shipper company logo image on the returned
label. This should be included as a Base64 encoded string.
Example:
<LogoImage>R0lGODlhAAQAA8QAANLlnLzXa+nyzvr886vNR…..</LogoImage>
<LogoImage> Element
<xsd:simpleType name="LogoImage">
<xsd:annotation>
<xsd:documentation>LogoImage</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:base64Binary">
<xsd:maxLength value="1048576" />
</xsd:restriction>
</xsd:simpleType>
Page 15 of 21
Implementing DHL XML Services
LogoImageFormat
Example:
<LogoImageFormat>GIF</LogoImageFormat>
<LogoImageFormat> element
<xsd:simpleType name="LogoImageFormat">
<xsd:annotation>
<xsd:documentation>LogoImage Format</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="PNG" />
<xsd:enumeration value="GIF" />
<xsd:enumeration value="JPEG" />
<xsd:enumeration value="JPG" />
</xsd:restriction>
</xsd:simpleType>
7.1.4.4 Resolution
<Resolution> indicates the DPI resolution required for label output on selected printer
Example:
<Resolution>200</Resolution>
<Resolution> element
<xsd:simpleType name="Resolution">
<xsd:annotation>
<xsd:documentation>Resolution</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:positiveInteger">
<xsd:minInclusive value="200" />
<xsd:maxInclusive value="300" />
</xsd:restriction>
</xsd:simpleType>
See ‘Appendix A – Sample Request including Label element’ to clarify the location of the
elements in the request.
Page 16 of 21
Implementing DHL XML Services
7.2 Response
The Shipment Validation Response returned will include the following additional elements:
<OutputFormat> which states the image type returned, corresponding to the content of
<LabelImageFormat> in the corresponding Shipment Validation Request
<OutputFormat> Element
<xsd:simpleType name="OutputFormat">
<xsd:annotation>
<xsd:documentation>OutputFormat</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="EPL2" />
<xsd:enumeration value="LP2" />
<xsd:enumeration value="PDF" />
<xsd:enumeration value="ZPL2" />
</xsd:restriction>
</xsd:simpleType>
<OutputImage> Element
<xsd:simpleType name="OutputImage">
<xsd:annotation>
<xsd:documentation>OutputImage</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:base64Binary" />
</xsd:simpleType>
See ‘Appendix B – Sample Response including Label elements’ to clarify the location of the
elements in the request.
Customers also have the option of using the Label utility which is included as part of the XML PI
Tool kit, to generate labels from the Shipment Validation Response.
Please refer to ‘Section 3.2 - Generate Global Label and Archive Label Images’ of the
‘ToolKit.pdf’ within the XML toolkit.
Page 17 of 21
Implementing DHL XML Services
Page 18 of 21
Implementing DHL XML Services
<CountryCode>GB</CountryCode>
<CountryName>United Kingdom</CountryName>
<Contact>
<PersonName>enquiry sing</PersonName>
<PhoneNumber>11234-325423</PhoneNumber>
</Contact>
</Shipper>
<LabelImageFormat>PDF</LabelImageFormat>
<RequestArchiveDoc>Y</RequestArchiveDoc>
<Label>
<LabelTemplate>8X4_thermal</LabelTemplate>
<Logo>Y</Logo>
<CustomerLogo>
<LogoImage>Base64:string</LogoImage>
<LogoImageFormat>GIF</LogoImageFormat>
</CustomerLogo>
<Resolution>200</Resolution>
</Label>
</req:ShipmentValidateRequestEA>
Page 19 of 21
Implementing DHL XML Services
<City>Beijing</City>
<PostalCode>100085</PostalCode>
<CountryCode>CN</CountryCode>
<CountryName>China</CountryName>
<Contact>
<PersonName>raobeert bere</PersonName>
<PhoneNumber>11234-325423</PhoneNumber>
</Contact>
</Consignee>
<Shipper>
<ShipperID>TCN</ShipperID>
<CompanyName>Test Company Name</CompanyName>
<AddressLine>Test Addr1</AddressLine>
<City>London</City>
<PostalCode>TW4 6JS</PostalCode>
<CountryCode>GB</CountryCode>
<CountryName>United Kingdom</CountryName>
<Contact>
<PersonName>enquiry sing</PersonName>
<PhoneNumber>11234-325423</PhoneNumber>
</Contact>
</Shipper>
<CustomerID>131297</CustomerID>
<ShipmentDate>2012-11-19</ShipmentDate>
<GlobalProductCode>D</GlobalProductCode>
<CustData>Customer information to be printed on the label</CustData>
<Billing>
<ShipperAccountNumber>130000279</ShipperAccountNumber>
<ShippingPaymentType>S</ShippingPaymentType>
<DutyPaymentType>R</DutyPaymentType>
</Billing>
<DHLRoutingCode>CN100085+42000000</DHLRoutingCode>
<DHLRoutingDataId>2L</DHLRoutingDataId>
<ProductContentCode>DOX</ProductContentCode>
<ProductShortName>EXPRESS WORLDWIDE</ProductShortName>
<DeliveryDateCode/>
<DeliveryTimeCode/>
<Pieces>
<Piece>
<PieceNumber>1</PieceNumber>
<Depth>200</Depth>
<Width>210</Width>
<Height>220</Height>
<Weight>20</Weight>
<PackageType>EE</PackageType>
<DimWeight>1848.000000</DimWeight>
<DataIdentifier>J</DataIdentifier>
<LicensePlate>JD011000000000534745</LicensePlate>
<LicensePlateBarCode> Base 64 Encoded String </LicensePlateBarCode>
</Piece>
</Pieces>
<LabelImage>
<OutputFormat>PDF</OutputFormat>
<OutputImage> Base 64 Encoded String </OutputImage>
</LabelImage>
</res:ShipmentValidateResponse>
Page 20 of 21
Implementing DHL XML Services
For development and testing, please use the following details, SiteID and Password are case
sensitive:
URL: https://xmlpitest-ea.dhl.com/XMLShippingServlet
SiteID: CIMGBTest
Password: DLUntOcJma
Your own DHL shipping account can be used in the test environment.
If you don’t have access to a DHL shipping account yet then please ask your DHL CIM
representative for advice.
There is an XML PI test harness available to assist when sending messages to the test server and
for additional sample code, which can be found using the following link:
http://xmlpitest-ea.dhl.com/serviceval/jsps/main/Main_menu.jsp
Page 21 of 21