Java – Simple Fax Transmission

Note that this is a deprecated sample. Please review the Java fax code samples section for newer samples.

Download the Java project files.
 class TestFax {  public static void main(String[] args) throws Exception
{
try {

    long result;
    // Create an instance of the Web Service Object
    InterFaxSoapStub ifs = new InterFaxSoapStub(new URL("https://ws.interfax.net/DFS.asmx"), new Service(new QName("SendCharFax")));

    // Invoke the SendCharFax method
    result = ifs.sendCharFax("MyUserName", "MyPassword", "+1-212-4567890", "This is a sample fax", "TXT");

    if (result > 0)

    // Positive returned value indicates that the fax was sent successfully.
    // The return value is the Transaction ID.
    System.out.println("Fax submitted properly. Transaction number: " + result);
    else
    // Negative returned value indicates sending failure.
    // See error code definitions
    System.out.println("Error sending fax!");

    } catch (Exception e) {
    System.out.println(e.toString());

    }
  }
}