All Articles
technical

CargoWise eAdapter DataContext Rules: The Guide Nobody Wrote

Understanding parent-level vs SubShipment DataContext rules is the difference between a working eAdapter integration and hours of debugging cryptic validation errors.

CargoWise eAdapter DataContext Rules: The Guide Nobody Wrote

If you have ever stared at a CargoWise eAdapter validation error that says absolutely nothing useful, you are not alone. The DataContext block is the single most misunderstood piece of eAdapter XML, and getting it wrong means your shipment data silently goes nowhere.

This guide covers the rules that WiseTech's documentation leaves you to discover the hard way.

What Is DataContext?

Every eAdapter XML message needs a DataContext block. It tells CargoWise who is sending the data, which company it belongs to, and where it should be routed. Think of it as the envelope around your shipment payload.

Here is what a complete parent-level DataContext looks like:

<UniversalShipment xmlns="http://www.cargowise.com/Schemas/Universal/2011/11">
  <ShipmentCollection>
    <Shipment>
      <DataContext>
        <Company>
          <Code>SYD</Code>
        </Company>
        <DataProvider>YOUR_PROVIDER_CODE</DataProvider>
        <EnterpriseID>YOUR_ENTERPRISE</EnterpriseID>
        <ServerID>YOUR_SERVER</ServerID>
        <DataTargetCollection>
          <DataTarget>
            <Type>ForwardingConsol</Type>
          </DataTarget>
        </DataTargetCollection>
      </DataContext>
      <!-- shipment fields here -->
    </Shipment>
  </ShipmentCollection>
</UniversalShipment>

Five elements. Miss one and you get a validation error. Include the wrong one in the wrong context and you get a different validation error.

The Parent-Level Rules

At the top-level Shipment (the consol or direct shipment), DataContext requires all five elements:

ElementPurposeWhat Happens If Missing
Company.CodeIdentifies the branch/officeRejected: "Company code is required"
DataProviderYour integration identityRejected: cannot authenticate
EnterpriseIDMulti-tenant routingRejected or routed to wrong environment
ServerIDTarget CW server instanceRejected or silent misroute
DataTargetCollectionWhat module to write intoRejected: "No DataTarget specified"

The DataTarget.Type value determines which CargoWise module receives your data. Common values:

  • ForwardingConsol — ocean/air consol shipments
  • ForwardingShipment — direct (non-consol) shipments
  • CustomsDeclaration — customs entries
  • TransportBooking — transport/cartage jobs

Critical mistake: Using ForwardingShipment when you mean ForwardingConsol. CargoWise will accept the XML, create a record in the wrong module, and you will spend a week wondering why your consol has no house bills attached.

The SubShipment Trap

When you send a consol with house bills (SubShipmentCollection), each SubShipment also needs a DataContext. But here is where developers get burned: SubShipment DataContext must be minimal.

<SubShipmentCollection>
  <SubShipment>
    <DataContext>
      <DataTargetCollection>
        <DataTarget>
          <Type>ForwardingShipment</Type>
        </DataTarget>
      </DataTargetCollection>
    </DataContext>
    <!-- house bill fields here -->
  </SubShipment>
</SubShipmentCollection>

Notice what is missing: no Company, no DataProvider, no EnterpriseID, no ServerID. The SubShipment inherits these from the parent.

If you include them, you get one of these:

  • "DataProvider is not valid at this level" — the clear one
  • "Unable to resolve target" — the vague one
  • Complete silence with your data written nowhere — the worst one

The Rule Table

ContextCompanyDataProviderEnterpriseIDServerIDDataTargetCollection
Parent ShipmentRequiredRequiredRequiredRequiredRequired
SubShipmentOmitOmitOmitOmitRequired

That is the entire rule. It should be on the first page of the eAdapter documentation. It is not.

Common Validation Errors and What They Mean

"No matching shipment found" — Your DataTarget type does not match the record type in CargoWise. You sent ForwardingShipment but the record is a consol.

"DataContext validation failed" — You are missing a required element at the parent level, or you included a forbidden element at the SubShipment level.

"Unable to determine target company" — The Company.Code does not match any branch configured in your CargoWise instance. Check the exact branch code in CW Administration.

No error at all, but data is missing — You sent the right DataContext but the wrong DataTarget.Type. CargoWise created a record in a module you are not looking at.

Debugging Checklist

  1. Parent level: Verify all five DataContext elements are present and correct
  2. SubShipment level: Verify DataContext contains ONLY DataTargetCollection
  3. DataTarget.Type: Confirm it matches the actual CW module (consol vs shipment vs customs)
  4. Company.Code: Confirm the exact branch code from CW Administration, not the display name
  5. Check the response: Even HTTP 200 does not mean success (see our ProcessingLog article)

Stop Guessing, Start Shipping

These DataContext rules took us months of production debugging to catalogue — across dozens of integrations with different CargoWise configurations. The patterns above will save you the most common headaches, but there are deeper traps around multi-company setups, cross-branch routing, and conditional DataTarget combinations.

Our Complete eAdapter Integration Guide covers every DataContext scenario we have encountered, with copy-paste XML templates and a validation checklist. If you are building or maintaining a CargoWise integration, it will save you weeks.

Get the Complete Guide →

Ready to automate your document processing?

Join freight forwarders saving hours every week with CargoMode.

Start for free