Example 52 : Creating a consignment with a non-USASCII characters

Printer-friendly version

This example demonstrates creating a consignment with accents on characters. Some carrier systems do not support anything other than US ASCII, so we transliterate during our communication with them.

package com.metapack.dm.test;
 
import com.metapack.deliverymanager.client.Consignment;
import com.metapack.deliverymanager.client.webservices.AllocationService;
 
public class Example52 extends ExampleBase {
 
	public void run() throws Exception {
		AllocationService service = createAllocationService();
		Consignment consignment = createDefaultConsignment( "EXAMPLE-52" , 1 );
		consignment.setRecipientName( "François du Færé" );
		Consignment[] createdConsignments = service.createAndAllocateConsignments( new Consignment[] { consignment } , null );
		Consignment createdConsignment = createdConsignments[ 0 ];
 
		if( createdConsignment.getCarrierConsignmentCode() == null ) {
			System.out.println( "The consignment could not be allocated" );
		} else {
			System.out.println( "The consignment was allocated and a given tracking code of " + createdConsignment.getCarrierConsignmentCode() );
		}
	}
 
}