This document reflects over the aforementioned use cases of the Sales and Returns API. All examples defined within demonstrate calls to the SOAP interface and are provided as is.
The following examples demonstrate calls to the Sales and Returns 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
ISAMSSalesReturnsAPI service = new ISAMSSalesReturnsAPI();
// User to authenticate with
String username = "Testing";
// Corresponding password to authenticate with
String password = "Sup94zex";
// Authenticate
ApiResponse authenticationResponse = service.authenticate(username, password);
String token = authenticationResponse.getMessage();
// Order ID for the Sale to search the Database for.
int saleID = 10501;
// Retrieve the Sale
SaleReturnApiResponse response =
service.retrieveSale(token, saleID);
// Examine the SaleReturnApiResponse for our Sale.
if (response.isSuccess()) {
System.out.println(response.getData()[0].getDispatchDate());
} else {
System.out.println("Failed to retrieve sale order.");
}
// Instantiate the web service proxy
ISAMSSalesReturnsAPI service = new ISAMSSalesReturnsAPI();
// User to authenticate with
String username = "Testing";
// Corresponding password to authenticate with
String password = "Sup94zex";
// Authenticate
ApiResponse authenticationResponse = service.authenticate(username, password);
String token = authenticationResponse.getMessage();
// OrderID
int returnID = 700;
// Call web service to retrieve a return order.
SaleReturnApiResponse response =
service.retrieveReturn(token, returnID);
// Check for success and process result
if (response.isSuccess()) {
System.out.println(response.getData()[0].getOrderID());
} else {
System.out.println("Failed to retrieve return order.");
}
// Instantiate the web service proxy
ISAMSSalesReturnsAPI service = new ISAMSSalesReturnsAPI();
// User to authenticate with
String username = "Testing";
// Corresponding password to authenticate with
String password = "Sup94zex";
// Authenticate
ApiResponse authenticationResponse = service.authenticate(username, password);
String token = authenticationResponse.getMessage();
// Call web service to list orders.
IntegerArrayApiResponse response =
service.listAll(token);
// Check for success and process result
if (response.isSuccess()) {
System.out.println("Number in list = " + response.getData().length);
} else {
System.out.println("Failed to retrieve return order.");
}
// Instantiate the web service proxy
ISAMSSalesReturnsAPI service = new ISAMSSalesReturnsAPI();
// User to authenticate with
String username = "Testing";
// Corresponding password to authenticate with
String password = "Sup94zex";
// Authenticate
ApiResponse authenticationResponse = service.authenticate(username, password);
String token = authenticationResponse.getMessage();
// Call web service to list orders.
IntegerArrayApiResponse response =
service.listFiltered(token, 2, null, null, null, 0);
// Check for success and process result
if (response.isSuccess()) {
System.out.println("Number in list = " + response.getData().length);
} else {
System.out.println("Failed to retrieve return order.");
}