The InterFAX Fax Web Service allows developers easy access to sending faxes from within applications. The service may be accessed directly from within Java development environments or through industry-standard SOAP interfaces which are readily available for a variety of scripting languages, such as Java, ASP, PHP, etc.
In this blog, I will show you how to use InterFax web service to send Fax from
your Force.com custom application.Learn More About InterFax
Prepare your self first….
1. Create Force.com developer account from developerforce.com
2. Create Developer Account on Interfax developer site. Save username and password, you will need them to send fax.
3. Download Outbound Fax WSDL.
Generate Apex Class from WSDL
As with most development platforms , Force.com provides a tool called WSDL2APEX to generate Apex class from WSDL file.
To connect with InterFax we will use Outbound Fax WSDL you have just downloaded.
Tweaking Interfax WSDL
At this point I assume you are well aware of WSDL. If not please read resources here
WSLD2APEX tool wont generate Apex class for you if your WSDL file has more than one wsdl:portType and/or more than one wsdl:binding ( Life is not easy man…!)
InterFax WSDL has 4 different port types and 4 corresponding bindings.
To send fax using InterFax, we will only need InterFaxSoap. So, remove all other 3 port definition and corresponding bindings. Save modified WSDL file on your file system.
- Login to your Force.com developer account.
- Go to Setup | Develop | Apex Classes
- Click on Generate from WSDL button
- Select Outbound Fax WSDL you have just tweaked.
- Leave default Apex class names as it is and click on Generate Apex code button.
The step 5 should have generated 2 classes for you,
Add Remote Site
Also you will need to add
Urls in remote site setting in your Force.com org. To add remote sites Go to
Setup | Security Controls | Remote Site
Settings and click New to create new remote site
This is to let Force.com know that you may call this site for data access and you trust this site.
Now let’s send Fax
When and to Whom your application will send fax depends on your design.
But in all case you will need
1. Destination Fax#
InterFax requires  format. i.e 912624002989
2. Document to Fax ( Of course Soft copy in this case…. )
Force.com provides means of rendering Visual Force page as PDF and getting PDF document in BLOB format.
See code snippet below
Blob b = null; Pagereference page = new Pagereference('URL to VF which has renderAs=PDF attribute '); b = page.getContent();
Use generated Apex class to send Fax
String s = EncodingUtil.base64Encode(b);
wwwInterfaxCc.InterFaxSoap interfax = new wwwInterfaxCc.InterFaxSoap ();
interfax.SendFax('InterFax Username','InterFax Password' , 'Destination Fax Number ',s, 'PDF' );
As we are using InterFax developer account to send Fax, we can only send fax to the Fax# which is registered with our Interfax developer account.With this web service you can even send fax in batches, you can cancel fax and you can even send character fax too. Study generated Apex class to find all the possibilities.