Java Fax - Cancel a Pending Fax

This sample allows you to cancel a Java fax that was previously submitted to the InterFAX Web service. This can be done using the CancelFax method. CancelFax only effects faxes waiting to be sent (with the status codes: -1 Preprocessing, -2 Ready, or -3 Pending Retry), and not faxes that actively-transmitted Java faxes.

The following Java fax snippet cancels a fax and checks if the cancellation succeeded.

The CancelFax code sample is also available as part of the ZIP file above (see the green 'Download' box), under the path interfaxJavaSamples > src > CancelPendingFax.


import net.interfax.outbound.CancelFax;
import net.interfax.outbound.CancelFaxResponse;

public class CancelPendingFax {

    /******** Begin settings ********/
    static String USERNAME = "";      // Enter your Interfax username here
    static String PASSWORD = "";      // Enter your Interfax password here
    static int TRANSACTION_ID = 999999999;   // Replace with the transaction ID of the fax to be canceled
    /******** End settings ********/

    public static void main(String[] anArgs) {
        try {
            net.interfax.outbound.InterFaxSoapStub theBinding = (net.interfax.outbound.InterFaxSoapStub)new net.interfax.outbound.InterFaxLocator().getInterFaxSoap();
            theBinding.setTimeout(60000);

            System.out.println("Canceling pending fax using CancelFax().");

            CancelFax params =
                new CancelFax(USERNAME,
                              PASSWORD,
                              TRANSACTION_ID );
            CancelFaxResponse response = theBinding.cancelFax( params );
            response.getCancelFaxResult();

            System.out.println("cancelFax() call returned with code: " + response.getCancelFaxResult());

        } catch(Exception theE) {
            theE.printStackTrace();
        }
    }
}

Contact us today

Talk to a member of our team about the benefits InterFAX can bring to your organization's communications processes.

Contact us today