Example 24 : Updating an existing consignment

Printer-friendly version

This example will find a consignment in the system, and will then modify some fields.

 

package com.metapack.dm.test;
 
import com.metapack.deliverymanager.client.Consignment;
import com.metapack.deliverymanager.client.webservices.ConsignmentSearchService;
import com.metapack.deliverymanager.client.webservices.ConsignmentService;
 
public class Example24 extends ExampleBase {
 
	public void run() throws Exception {
		ConsignmentSearchService service = createConsignmentSearchService();
		ConsignmentService consignmentService = createConsignmentService();
		Consignment consignment = service.findConsignmentByConsignmentCode( "DMC01V00M8NR" );
		if( consignment == null ) {
			System.out.println( "Consignment not found" );
		} else {
			consignment.setRecipientName( "Bill Gates" );
			consignment.setRecipientEmail( "bill.gates@microsoft.com" );
			consignmentService.updateConsignments( new Consignment[] {consignment} );
		}
	}
}