Magento – Magento 2: DHL Shipping Method Element type “NewShipper” must be declared

dhlmagento2shipping-addressshipping-methods

I'm using DHL Shipping Method. After Order Placed. While creating New Shipment i have cliced on "Create Shipping Label" & Clicked on "Submit Shipment".

On popup i have filled info. While saving it's giving below error

Error #111 : Error in parsing request XML:Error: Element type
"NewShipper" must be declared. at line 2, column 320

In debug i have below Request XML file

<?xml version="1.0" encoding="UTF-8"?>
<req:ShipmentValidateRequestAP xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com ship-val-req_AP.xsd">
   <Request>
      <ServiceHeader>
         <SiteID>XXXXXX</SiteID>
         <Password>11111</Password>
      </ServiceHeader>
   </Request>
   <NewShipper>N</NewShipper>
   <LanguageCode>EN</LanguageCode>
   <PiecesEnabled>Y</PiecesEnabled>
   <Billing>
      <ShipperAccountNumber>1111111</ShipperAccountNumber>
      <ShippingPaymentType>S</ShippingPaymentType>
      <BillingAccountNumber>1111111</BillingAccountNumber>
      <DutyPaymentType>S</DutyPaymentType>
      <DutyAccountNumber>1111111</DutyAccountNumber>
   </Billing>
   <Consignee>
      <CompanyName>Test Company</CompanyName>
      <AddressLine>S. G. Highway</AddressLine>
      <City>Ahmeabad</City>
      <Division>Gujarat</Division>
      <PostalCode>1111111</PostalCode>
      <CountryCode>IN</CountryCode>
      <CountryName>India</CountryName>
      <Contact>
         <PersonName>John</PersonName>
         <PhoneNumber>9999911111</PhoneNumber>
      </Contact>
   </Consignee>
   <Commodity>
      <CommodityCode>1</CommodityCode>
   </Commodity>
   <Dutiable>
      <DeclaredValue>107.50</DeclaredValue>
      <DeclaredCurrency>SGD</DeclaredCurrency>
   </Dutiable>
   <Reference>
      <ReferenceID>shipment reference</ReferenceID>
      <ReferenceType>St</ReferenceType>
   </Reference>
   <ShipmentDetails>
      <NumberOfPieces>1</NumberOfPieces>
      <CurrencyCode>SGD</CurrencyCode>
      <Pieces>
         <Piece>
            <PieceID>1</PieceID>
            <PackageType>CP</PackageType>
            <Weight>1</Weight>
            <Depth>12</Depth>
            <Width>6</Width>
            <Height>6</Height>
            <PieceContents>Dog Zodiac Bookmark,2008 URA 4-In1</PieceContents>
         </Piece>
      </Pieces>
      <PackageType>CP</PackageType>
      <Weight>1</Weight>
      <DimensionUnit>C</DimensionUnit>
      <WeightUnit>K</WeightUnit>
      <GlobalProductCode>P</GlobalProductCode>
      <LocalProductCode>P</LocalProductCode>
      <DoorTo>DD</DoorTo>
      <Date>2016-12-09</Date>
      <Contents>DHL Parcel TEST</Contents>
   </ShipmentDetails>
   <Shipper>
      <ShipperID>1111111</ShipperID>
      <CompanyName>The Singapore</CompanyName>
      <RegisteredAccount>1111111</RegisteredAccount>
      <AddressLine>Singapore</AddressLine>
      <City>SINGAPORE</City>
      <Division>SINGAPORE</Division>
      <PostalCode>608928</PostalCode>
      <CountryCode>111111</CountryCode>
      <CountryName>Singapore</CountryName>
      <Contact>
         <PersonName>Singapore</PersonName>
         <PhoneNumber>+65111111</PhoneNumber>
      </Contact>
   </Shipper>
   <LabelImageFormat>PDF</LabelImageFormat>
</req:ShipmentValidateRequestAP>

Below is Response XML File

<?xml version="1.0" encoding="UTF-8"?><res:ErrorResponse xmlns:res=\'http://www.dhl.com\' xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xsi:schemaLocation= \'http://www.dhl.com err-res.xsd\'>
    <Response>
        <ServiceHeader>
            <MessageTime>2016-12-09T08:48:11+01:00</MessageTime>
            <SiteID>XXXXXX</SiteID>
            <Password>XXXXXXX</Password>
        </ServiceHeader>
        <Status>
            <ActionStatus>Error</ActionStatus>
            <Condition>
                <ConditionCode>111</ConditionCode>
                <ConditionData>Error in parsing request XML:Error:
                    Element type &quot;NewShipper&quot; must be
                    declared. at line 2, column 320</ConditionData>
            </Condition>
        </Status>
    </Response></res:ErrorResponse>

I'm in LIVE Mode of DHL.

Best Answer

Since DHL is updating their XML Schema, you need to update also the request XML of Magento.

You need to update this file:

Magento Root Files\vendor\magento\module-dhl\Model\Carrier.php