Contract Shipping

Code Samples for Contract Shipping: Java (.zip) | PHP (.zip) | C# (.zip)

Get Shipment – SOAP

Summary

Name: Get Shipment
Reason to Call: To retrieve information related to a previously created shipment. This may be useful for recovery from a communication or other error and/or reporting on all outstanding shipments.

Note: any shipments that are transmitted (i.e. have been part of a successful Transmit Shipments) will not be accessible by this service.

Input: Shipment-id; mailed-by; locale (optional).
Output: Identification numbers for the information associated with the created shipment, including a shipment ID, the parcel identification numbers (PIN) for tracking and artifact IDs for accessing labels.

These identification numbers will remain accessible to you for 90 days or until you void the shipment.

Typical Prior Call: Create Shipment, Get Shipments or Get Manifest Details
Typical Next Call: Get Artifact, Get Shipment Price, Get Shipment Details
Version history: Release notes
Get Shipment – Summary of Service

Get Shipment – Summary of Service

Call Details

WSDL: shipment.wsdl
Endpoint (Development): https://ct.soa-gw.canadapost.ca/rs/soap/shipment/v8
Endpoint (Production): https://soa-gw.canadapost.ca/rs/soap/shipment/v8
Namespace: http://www.canadapost.ca/ws/soap/shipment/v8
Operation: GetShipment

SOAP Body

This section describes the XML input elements to this service. For the hierarchical structure, see the XML diagram.

Get Shipment – Request Elements
Element Name Type Required / Optional Description

get-shipment-request

complex

required

The top level XML element for the request input information.

mailed-by

simple

required

(1-10 digit numeric)

The 10-digit customer number of the mailed-by customer.

If the number provided has fewer than 10 digits, the system will add leading zeros.

mobo

simple

optional

(1-10 digit numeric)

The 10-digit customer number of the mailed-on-behalf-of customer.

If this element is missing, it will default to the mailed-by customer number.

If the number provided has fewer than 10 digits, the system will add leading zeros.

locale

simple

optional

Indicates your language preference for receiving error messages.

EN = English
FR = French

If no value is provided, the default language is English.

shipment-id

simple

required

(Alphanumeric String – up to 32 letters/digits)

An identification number representing the existing shipment for which information is being requested.

Note: Retrieve the shipment-id provided by previous calls to Create Shipment or Get Shipment. The output of those services will include a shipment-id element.

Request – XML Diagram

Get Shipment – Structure of the XML Request

Get Shipment – Structure of the XML Request

Response Details

Response – Elements

The following table describes the XML elements in the response to Get Shipment. For the hierarchy of the response, see the XML diagram.

Get Shipment – Response Elements
Element Name Type Description

get-shipment-response

complex

The top level XML element for the response.

It will either contain the results of a successful completion or the error message structure.

shipment-info

complex

The XML structure containing the results of a successful completion of the service.

customer-request-id

simple

Your unique transaction ID, if you supplied it in your request.

shipment-id

simple

A unique identifier for the shipment. Use it for all other calls related to the shipment.

shipment-status

simple

Indicates the current status of the shipment. Valid values are:

  • created
  • transmitted
  • suspended

tracking-pin

simple

The tracking PIN for the shipment. It can be used as input to other web service calls such as Get Tracking Details.

return-tracking-pin

simple

The tracking PIN for the return shipment. It can be used as input to other web service calls such as Get Tracking Details.

group-id

simple

The name of the group in which the shipment was created. The group name is unique within the domain of the mailed-on-behalf-of customer.

artifacts

complex

The structure that contains information to allow you to access the various labels (artifacts) for the shipment.

You can retrieve the labels using this information and the Get Artifact service.

artifact

complex

This represents an individual label (artifact) for the shipment

May occur 1 .. N times.

This element will include an attribute type="XXX"
where XXX= the type of label that this artifact represents.

There are 4 possible values for this attribute associated with 4 types of labels:

  • "label" – the primary shipping label
  • "returnLabel" – the label for a return delivery
  • "codRemittanceLabel" – the label for COD remittance
  • "codRemittanceReturnLabel" – the label when a COD remittance return is required.

artifact-id

simple

Represents a unique identifier for the label (artifact) and is required as part of a request to Get Artifact to retrieve the label.

page-index

simple

Note: This element is always zero for PDF since PDF supports multiple pages. It is not required in requests to retrieve PDF documents.

Response – XML Diagram

Get Shipment – Structure of the XML Response
Get Shipment – Structure of the XML Response

Response – Possible Error Responses

The response to error conditions for this web service follows the standard SOAP error response approach used for all Canada Post web services. For more information, see SOAP Fundamentals of Canada Post Web Services.

Examples

Sample SOAP XML Request – Get Shipment

<get-shipment-request>
<mailed-by>1111111</mailed-by>
<locale>EN</locale>
<shipment-id>340531309186521749</shipment-id>
</get-shipment-request>

Sample SOAP XML Response – Get Shipment

<get-shipment-response>
<shipment-info>
<shipment-id>340531309186521749</shipment-id>
<shipment-status>created</shipment-status>
<tracking-pin>1111111883561103</tracking-pin>
<group-id>123456</group-id>
<artifacts>
<artifacttype="label">
<artifact-id>10238</artifact-id>
<page-index>0</page-index>
</artifact>
</artifacts>
</shipment-info>
</get-shipment-response>