Faxing from EBS

Fax integration is probably one of the most popular and tougher delivery destinations from the EBS, you need connections to the fax server from EBS, you need to be able to convert your documents to a tif format, you may need very high volumes of faxes, your users will want to be able to monitor the delivery and have automatic redial if the fax recipient's machine is busy. This has required third parties and Oracle Partners to provide functionality for faxing documents.
The XMLP faxing solution aleviates some of these issues but it is not a replacement for some of the fine solutions out there.


What can it do?


  • XMLP can send a fax via the IPP protocol, this requires a delivery server such as CUPS to handle the fax the request.
  • XMLP can be integrated into the concurrent manager or even a specific product
  • XMLP can be used for lightweight faxing requirements
  • You can build a complete faxing solution using the XMLP APIs
What can't it do?



  • It can not handle huge volumes of faxing, Im talking thousand of faxed an hour
  • No out of the box redial and monitoring EBS UI. CUPS has its own UI that could be used.

If you're still interested in building a fax delivery channel then you can use the java APIs and the shell script in conjunction with a dummy printer driver. Again, you can extend your implementation as much as you want so you can build feedback into the concurrent manager or even build your own fax monitoring UI interface.

For this demo we'll take a similar approachto that of the email solution. We'll need a CUPS server set up to communicate the fax content to. CUPS is only for UNIX or LINUX implementations, for those of you on a Windows there are commercial solutions available to have a FAX machine connected to your network via IPP. We will also use the database querying to grab the fax number.

Step1: Set up CUPS


The set up of CUPS for faxing is covered in the user guide (pg 11-36) you'll need some extra packages and install them. The good news is that they are all open source solutions and therefore inexpensive, the not so good news is that support is going to be patchy. Follow the instructions and test that the fax machine is sending output when called.

Step 2: Build the java class

We can reuse much of the email code we wrote last time. We of course need to use the fax APIs rather than the Email. We also need to fetch the fax number of course, you can use the techniques we used last. For this example I decided to try something different. Im assuming that the report that is to be delivered actually has the fax number embedded inside it. In this case we can fetch the XML data used to create the report, parse it and retrieve the fax number value.
I have been a little lazy with my class, it parses and sends the document, if you were going to use the parser functionality across multiple delivery classes then you would break it out on its own.
I use the SAXParser rather than the DOM, we're not sure how much data we are going to get and do not want to gobble up memory loading the whole document using the DOM parser.
In the class I have I just have a few methods to:


  1. Parse the document - the parser just moves through the document and event are fired that we can subscribe to.
  2. Look for the specific element that holds the fax number - once found its sets a flag for the next method to
  3. Fetch the fax number value into a variable and sets another 'found the element' flag for the next function
  4. Check the closing element that holds the fax number - if the flag is set then the parser stops working through the document.


Heres the code snippet for the parser, the startElement, endElement and characters methods are standard SAXParser methods we need to implement:


  public String parseFAXNum (String xmlFile)
  {
    try {
         
          SAXParser parser = new SAXParser();
//Because Im lazy my class is extending the DefaultHandler for SAX
// so I can just use 'this' for the following methods



          parser.setContentHandler(this);
          parser.setErrorHandler(this);
          // We parse the XML file fetched from the variables passed
// from the printer driver
          parser.parse(xmlFile);
         
    }
          catch (Exception ex) {
                System.out.println(ex);
          }
        return(xFaxNum);
  }
 
  public void startElement(String uri, String localName,
          String rawName, Attributes attributes) 
          // We're checking for the CUST_FAX_NUM element, this method
// looks for the opening tag. If found then we set a
// "found" flag to true for the "characters" method

       {
             if (localName.equals("CUST_FAX_NUM"))
             {
                getEleVal = true;
              }
       }
  public void endElement (String uri, String localName,
          String rawName) throws SAXException
          {
         // We're checking for the CUST_FAX_NUM element, this method looks
// for the closing tag.
         // If found then we throw an exception to stop the parser.
            if (localName.equals("CUST_FAX_NUM"))
            {
               getEleVal = false;
               throw new SAXException("Found element required");
             }
          }
    public void characters(char[] cbuf, int start, int len) 
      {
         if (getEleVal)
         {
           // We have the value we want so assign it to the fax variable
           xFaxNum = new String(cbuf,start,len);
           
         }
      }
If you wanted to break the parser out on its own and use it for multiple report output you could place the logic in the code to check the root of XML ie RAXINV for the Invoice report, POXRPOP for Purchase Orders and then find the appropriate element for the fax number.

Once we have the fax number we're pretty much set to call the appropriate APIs to deliver the document.
    try
    {
      // fetch the fax number from the XML data that is
      // fetched via the requestid from the driver
      String faxx  = parseFAXNum(getXMLFile(requestid));
      // create delivery manager instance
      DeliveryManager dm = new DeliveryManager();
      // create a delivery request
      DeliveryRequest req = dm.createRequest(DeliveryManager.TYPE_IPP_FAX);
      // set IPP fax host - this is our CUPS server
      req.addProperty(DeliveryPropertyDefinitions.IPP_HOST,
"xdodev2.us.oracle.com");
      // set IPP fax port - - this is our CUPS server port
      req.addProperty(DeliveryPropertyDefinitions.IPP_PORT, "631");
      // set IPP fax name - this is our CUPS fax name
      req.addProperty(DeliveryPropertyDefinitions.IPP_PRINTER_NAME,
"/printers/fax1");
      // set the document format
      // we can pass a pdf document and CUPS will convert it to tiff for us
      req.addProperty(DeliveryPropertyDefinitions.IPP_DOCUMENT_FORMAT,
"application/pdf");
      // set the phone number to send
      req.addProperty(DeliveryPropertyDefinitions.IPP_PHONE_NUMBER, faxx);
      // set the document
      req.setDocument(rFile);
      // submit the request
      req.submit();
      // close the request
      req.close();
    }

You might have noticed that we are  passing a pdf format to the CUPS server, CUPS will convert the pdf to tiff format for us. You can see the complete class definition here.


Now all you need do is create a new fax "printer" driver to call your class and you now have faxing from the EBS with some level of flexibility for your users.
If you are looking at handling a batch of documents, XMLP has a much better solution in its Bursting Engine and I'll cover that once I have completed the delivery articles.


Happy Faxing!

Comments:

Thank you so much for the code for emailing and faxing. They have worked quite well and been very helpful.

Posted by Sandra Whiting on April 20, 2007 at 03:13 AM MDT #

Hi Sandra, Glad it helped. Regards, Tim

Posted by Tim Dexter on April 20, 2007 at 03:18 AM MDT #

Is the complete class definition still available? I wasn't able to get it through this post. Thanks! K. Hale

Posted by K. Hale on July 28, 2008 at 03:02 AM MDT #

Hi K I have not posted the full code - just the important bits Tim

Posted by Tim on August 04, 2008 at 03:14 AM MDT #

I need to admit that this text proved to be very helpful in my paper research Thank you! Tassimo T Disc

Posted by Marianne Versage on February 24, 2010 at 11:36 AM MST #

Hi Tim, This is very Excellent post for sending Email and faxs. Thank You, Anil Kumar

Posted by Anil kumar on February 25, 2010 at 10:16 PM MST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Follow bipublisher on Twitter Find Us on Facebook BI Publisher Youtube ChannelDiscussion Forum

Join our BI Publisher community to get the most and keep updated with the latest news, How-to, Solutions! Share your feedback and let us hear your voice @bipublisher on Twitter, on our official Facebook page, and Youtube!

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today