The following guide demonstrates how to use the USAePayResApi-jaxws.jar package with either Sun's Jax-WS 2.1 or Apache Foundation's CXF libary. This package contains a helper class for easily generating security tokens, classes for all USAePay objects and a client service class for calling web service methods. The package requires Jax-WS (see Dependencies).
In classes that are going to use the USAePay methods or object, you need to import the appropriate classes from com.usaepay.resapi.jaxws package. The following will import all usaepay objects at once:
All calls to the USAePay web service are handled by a “client” object of type “UeSoapServerPortType”. There are two ways to instantiate the client object. To instantiate a client for use with the main production servers:
// Instantiate client for production UeSoapServerPortType client = usaepay.getClient();
Alternately, you can specify a server hostname, which will allow you to setup a connection to the sandbox server for testing or a backup datacenter (see the high availability programming guide).
// Instantiate client for sandbox UeSoapServerPortType client = usaepay.getClient("sandbox.usaepay.com");
A “restoken” object (of type UeSecurityToken) is required by all methods in the USAePay Reseller API. It is used to identify and authenticate the reseller.
Web service methods are called using the client object. Below is an example for calling the getMerchant method. For further examples see the api documentation.
// Set the merchant ref num (merchid) BigInteger merchrefnum = new BigInteger("118227"); // Create response object Merchant merch; // Retrieve Merchant merch = client.getMerchant(restoken, merchrefnum); // Display response System.out.println("Merchant: " + merch.getMerchantName());
For addition documentation on which methods are available and example usage, please see the main Reseller API Documenation. The documentation includes a description of all methods and their parameters as well as examples for the java library.
If you run into any trouble please contact our integration support department.