This document reflects over the aforementioned use cases of the Dispatch API. All examples defined within demonstrate calls to the SOAP interface and are provided as is.
The following examples demonstrate calls to the Dispatch API in Java. Java examples demonstrated here assume the use of a generated XML web service client. To generate such a client, a tool such as wsdl2java can be used. A detailed description on this tool can be found on the Apache Web Services website, but all you will need to do is point it at your site's WSDL description.
// Instantiate the web service proxy.
DispatchAPI service = new DispatchAPI();
// User to authenticate with.
String username = "Testing";
// Corresponding password to authenticate with.
String password = "Sup94zex";
// Authenticate
ApiResponse authenticationResponse = service.authenticate(username, password);
// Dispatch Point name to search the Dispatch Database for.
String dispatchPointName = "Dispatch Point 1";
// Retrieve the dispatch point
DispatchPointApiResponse retrieveResponse =
service.retrieveDispatchPoint(
authenticationResponse.getMessage(), dispatchPointName
);
// Examine the DispatchPointApiResponse for our dispatch point.
if (retrieveResponse.getData()[0] == null) {
System.out.printf(
"Failed to retrieve dispatch point: %s", dispatchPointName
);
} else {
// Extract the dispatch point from the response.
DispatchPoint dispatchPoint = retrieveResponse.getData()[0];
}
// Instantiate the web service proxy.
DispatchAPI service = new DispatchAPI();
// User to authenticate with.
String username = "Testing";
// Corresponding password to authenticate with.
String password = "Sup94zex";
// Authenticate
ApiResponse authenticationResponse = service.authenticate(username, password);
// List all the dispatch points available for the authenticated user.
DispatchPointApiResponse listResponse =
service.listDispatchPoints(authenticationResponse.getMessage());
for(DispatchPoint dispatchPoint : listResponse.getData()) {
System.out.printf(dispatchPoint.getCode());
}
// Instantiate the web service proxy.
DispatchAPI service = new DispatchAPI();
// User to authenticate with.
String username = "Testing";
// Corresponding password to authenticate with.
String password = "Sup94zex";
// Authenticate
ApiResponse authenticationResponse = service.authenticate(username, password);
// Dispatch Point name to search the Dispatch Database for.
String dispatchPointName = "Dispatch Point 1";
// Obtain a list of order IDs for the provided dispatch point.
IntegerArrayApiResponse listResponse = service.listOrders(
authenticationResponse.getMessage(), dispatchPointName
);
for(Integer orderID : listReponse.getData()) {
System.out.printf(orderID);
}
// Instantiate the web service proxy.
DispatchAPI service = new DispatchAPI();
// User to authenticate with.
String username = "Testing";
// Corresponding password to authenticate with.
String password = "Sup94zex";
// Authenticate
ApiResponse authenticationResponse = service.authenticate(username, password);
// Barcode and Dispatch Point name to use.
String barcode = "APN_1_2";
String dispatchPointName = "Dispatch Point 1";
// Execute the action and obtain the response
IntegerArrayApiResponse actionResponse = service.allocateBarcode(
authenticationResponse.getMessage(), dispatchPointName, barcode
);
// Examine the IntegerArrayApiResponse for our order item id.
if (actionResponse.getData()[0] == null) {
System.out.printf("Failed to allocate item: %s", barcode);
} else {
// Extract the order item id from the response.
Integer orderItemID = actionResponse.getData()[0];
}
// Instantiate the web service proxy.
DispatchAPI service = new DispatchAPI();
// User to authenticate with.
String username = "Testing";
// Corresponding password to authenticate with.
String password = "Sup94zex";
// Authenticate
ApiResponse authenticationResponse = service.authenticate(username, password);
// Order ID and Dispatch Point name to use.
int orderID = 12345;
String dispatchPointName = "Dispatch Point 1";
// Execute the action and obtain the response
ApiResponse actionResponse = service.assignOrder(
authenticationResponse.getMessage(), dispatchPointName, orderID
);
// Check the ApiResponse for success/failure.
if (actionResponse.getSuccess()) {
System.out.printf("Successfully assigned order: %i", orderID);
} else {
System.out.printf("Failed to assign order: %i", orderID);
}