Example 02 : Creating a consignment

Printer-friendly version

This demonstrates how the basic functionality of what the examples do. It will create a single parcel Consignment object (using the createDefaultConsignment() function, implemented in the base class), with an order reference of "EXAMPLE-2". Then it will submit it to the Web Service for creation in the DM system.

The createDefaultConsignment() is local to the client - nothing is sent to the server until the service.createConsignments() call is made.

If the creation in DM fails for any reason (such as invalid postcodes), the service will respond with a fault code as an exception.

 

package com.metapack.dm.test;
 
import com.metapack.deliverymanager.client.Consignment;
import com.metapack.deliverymanager.client.webservices.ConsignmentService;
 
public class Example2 extends ExampleBase {
 
	public void run() throws Exception {
		ConsignmentService service = createConsignmentService();
		Consignment consignment = createDefaultConsignment( "EXAMPLE-2" , 1 );
		service.createConsignments( new Consignment[] { consignment } );
	}
 
}