import cc.interfax.www.Sendfax;
import cc.interfax.www.SendfaxResponse;
public class SendFaxTest {
public void run() throws Exception {
cc.interfax.www.InterFaxSoapStub theBinding;
try {
theBinding = (cc.interfax.www.InterFaxSoapStub)
new cc.interfax.www.InterFaxLocator().getInterFaxSoap();
}
catch (javax.xml.rpc.ServiceException jre) {
if(jre.getLinkedCause()!=null)
jre.getLinkedCause().printStackTrace();
throw new RuntimeException("JAX-RPC ServiceException caught: " + jre);
}
// Time out after a minute
theBinding.setTimeout(60000);
// Encode the File.
byte[] theFileData = TestUtils.transformToBytes(TestConstants.PDF_FILENAME);
System.out.println("Sending Fax using sendFax(). Document size: " + theFileData.length);
Sendfax theParams = new Sendfax(TestConstants.USERNAME,
TestConstants.PASSWORD,
TestConstants.FAX_NUMBER,
theFileData,
"PDF");
SendfaxResponse theResponse = theBinding.sendfax(theParams);
System.out.println("sendFax() call returned with code: " + theResponse.getSendfaxResult());
}
public static void main(String[] anArgs) {
try {
new SendFaxTest().run();
} catch(Exception theE) {
System.out.println("Error encountered while running SendFaxTest:");
theE.printStackTrace();
}
}
}
|