Java Web Services

Java Web Services

Java is the default language for HEAT LiveTime. There are many ways to program web services using Java, as there is a rich infrastructure already present in the language. The high transactional rate and scalability of the language make it perfect for more complex Web Services applications, fault tolerance and communication with other applications.

We have provided a link to the complete source code of a more complex application. Our Web Services are based on Apache Axis 1.x in these examples for the greatest compatibility with existing applications.

Feel free to use this code as the basis for you own applications.

In order to communicate with the HEAT LiveTime web services you should have a thorough knowledge of SOAP and also HEAT LiveTime Web Services API’s. HEAT LiveTime has a developers guide which details each of the API calls and how to use them. What follows are scripts you can use to handle some of the more difficult parts of communication. Notably session management.

package com.heat.livetime.sample;


public class CreateCustomer extends BaseClient {

	/* Customer Service URL */
	public static final String customerServiceURL = "";

	/* Constructor - doesn't need to do anything coz this is just a sample */
	public CreateCustomer() {


	private boolean createCustomer() { custURL = null;

		try {
			// Service endpoint
			custURL = new;

			// Get handle to the service
			Customer_Service service = new Customer_ServiceLocator();
			Customer_PortType port = service.getCustomer(custURL);

			// Call BaseClient method to populate persistent headers

			// create properties you want to set for this person - properties you may want to set here:

			// custom1 (String 255), custom2(String 255), custom3(String 255), custom4(String 255), custom5(String 255),
			// aliases (comma separated list of email addresses), orgunit (String - case insensitive match to a HEAT LiveTime org unit),
			// phone(String 32), phone2(String 32), phone3(String 32), address(String 128), addressTwo(String 128), postalCode(String 32), city(String 64),
			// country (Integer as String - must be id from getCountries() call), state(Integer as String - must be id from getStatesForCountry(String countryId) call)

			java.util.HashMap<String, String> properties = new java.util.HashMap<String, String>();
			properties.put("phone", "+1 949 777 5800");
			properties.put("phone2", "+61 3 9620 7588");

			// So this is generally reusable without scrubbing database each time, we add a random number after the username & email
			// wouldn't do this in the real world obviously - but I'll mention it in case someone tries :p
			String suffix = Integer.toString((new Double(Math.random() * 1000000)).intValue());

			// username, email, first name, last name, properties (above)
			java.util.HashMap response = port.createCustomer("bob_" + suffix, "bob_" + suffix + "", "Bob", "Nelson", properties);

			// Just output stuff from here on
			String successString = response.get("success").toString();
			boolean successful = Boolean.parseBoolean(successString);

			if(!successful) {
				System.out.println("Customer Creation failed: " + response);
			else {
				System.out.println("Customer Creation succeeded: " + response);

			return successful;
		catch(Exception ex) {
			return false;

	// Entry point for execution
	public static void main(String[] args) {
		// create instance of this class
		CreateCustomer createCustomer = new CreateCustomer();
		// try and connect, if successful, create customer and logoug
		if(createCustomer.connect()) {
			// create the customer
			// logout