Business Process Modeling - BTMSoftwareSolutions.com

Wednesday, November 24, 2010

RESTful Service From Email Using Orbeon to Intalio

In a previous blog, I wrote about how you could use Intalio REST Connector to call an LDAP service created in Orbeon XPL.  In this blog I take a different tactic in using Orbeon and Intalio to meet a clients needs.

The client project entailed creating a reminder/alerting service using Intalio as the business rules service.  If a timer expires before an updated message comes in to the process, emails are to be sent out to staff and manager.  In the email, they wanted the capability of checking a box and replying to the email which would end the Intalio Process for monitoring that case if monitoring was no longer required.  So this is what I put together for them using Intalio and Orbeon.

When the email is sent, I format the body of the email using Intalio bpel:doXSLTransform function and in the xsl include HTML and values from the process.  As part of the html email I include a link which is formatted to call an Orbeon XPL file - a RESTful service.  In the url is the location of the service and the necessary parameters.  An example of the url format is below:

http://{ip}:{port}/orbeon/{appName}/{pagePath}?{parameter1}={value}&........

So, all this does is call the xpl file location which does the following.
  1. First we use an xsl processor to take the parameters from the url and put them in the pattern required by the delegation processor.
  2. The output of the xsl processor is passed to the input for the call of the delegation processor.  The delegation processor is configured to call Intalio Web Service.
  3. Intalio receives the message and responds back with the results, which in the case is just that the message was received.
  4. An xsl processor takes the result from the delegation processor and displays that result in the users browser.
So, in this example we were able to call a web service (in this example the service endpoint was located in Intalio as part of a business process) from within an email using orbeon as the RESTful service provider.

Thinking outside the box, Orbeon components were used without displaying one single xForms to add functionality to our process.

If you would like more information or would like to implement something similar in your organization, contact us at http://btmsoftwaresolutions.com.

Sunday, November 14, 2010

Intalio - Orbeon Email Service

In a previous post I provided an example of how you could combine Orbeon and Intalio using rest to retrieve information from an LDAP and use it within a business process.  In this post I will describe a completed email service using this approach with the ability to send in multiple LDAP filters and send multiple emails.

The concept was as follows - allow a process or a user to send in multiple LDAP filter criteria and send emails to all those users returned from the service.  For example, a process may want to send an email to not only one user (cn='userID'), but also that user and a everyone with the title supervisor (title='supervisor'). 

Email service explained.

Email service contract expects the following:
  1. A subject for the email
  2. A body for the email (can send in a nicely formatted HTML)
  3. The LDAP attribute(s) you want to filter and the value(s) - 1 to many
    • cn, userID
    • title, supervisor
The process first counts the number of LDAP parameters being sent in and sets an in process variable to this value - $countFilters.  This variable is set within a main looping sub-process.  The main sub-process exits only when the number of loops equals the number of $countFilters.  We also set a variable $ldap to yes and the $mainLoop variable to 1.  Finally we set a variable $countNodes to 0.  This tells this email sub-process (explained next) gateway whether to call the LDAP REST service.  If $ldap set to yes, the LDAP Service is called.  If set to no, then bypass the LDAP service.

The process then enters another sub-process (email sub-process).  The first thing this process does is set the in process variable $countNodes to $countNodes +1.  Remember $countNodes is set to 0 by default in the main sub-process because if we have multiple LDAP parameters being sent in, when the email sub-process is completed we may have to start all over again so we have to reset $countNodes.  This email sub-process will only exit when $countNodes equals count(result)  - the xpath function count() of the result nodes returned from the LDAP Rest service.  Next a gateway evaluates the $ldap variable and since we set it to yes, we call LDAP REST service.  We pass in the first filter by using the Intalio data editor and then in process variable $mainLoop to select the node position.  So, params/attribute[$mainLoop] and params/filter[$mainLoop].  LDAP returns 1 or more user information and then we start sending emails.  We use the $countNodes variable to iterate through all the potential results.  So to get the first email, we say results/result[$countNodes]/attribute[name='mail']/value.  This gives us the first person's email.  After the email is sent, we set the $ldap variable to no, because we do not need to call ldap again at this point.  If more emails are to be sent, we loop back in the email sub-process, do not go LDAP REST service because we set $ldap to no and $countNodes is now set to 2.  The next email will be sent.  If there are no emails, then $countNodes = count(result) and we exit the email sub-process.  But, if we sent in more then one LDAP filter, we loop back to the very beginning of the main sub-process because $countParams does not equal count(params).  We also set $mainLoop to 2 and $ldap variable to yes because we need to call the LDAP REST service again to get new user(s) information.  So, we take the next LDAP filters based on node position the user sent in and start the entire email sub-process over.  When email sub-process completes again, if $mainLoop = count(params), then we exit the main sub-process and the email service ends.

You can call this email service from within an existing business process designed in Intalio or an external system since the email service generated in Intalio provides you with a WSDL.  So for example, you could call this email service from within Orbeon.

If you would like to implement something similiar in your organization, contact BTM Software Solutions for more information.

Friday, November 12, 2010

LDAP connector using Orbeon and Intalio

In my business processes that I develop for customers they often want email notifications sent for alerts and or events that happen along the business process.  The user information is stored in Apache DS LDAP so the trick is getting the data in the process to be used for html emails.  I came up with a solution several months back which involved using openESB and their LDAP Binding Connector (BC) to create a composite application deployed on Glassfish Server.  The Trigger was an HTTP SOAP call which passed information to the LDAP BC and returned the desired results.

Even though this solution got the job done, you had to download openESB, develop the composite application in Netbeans, deploy the process to GlassFish Server, etc.  More tools, possibility for errors, something else to learn, something else to support and servers running just for basic LDAP information.

The product I use for Business Process workflow is Intalio.  And although they currently do not have an LDAP Connector, they do have a REST connector.  Another product I use is Orbeon xForms.  Orbeon does have the ability to query an LDAP through XML Pipe Line (XPL).  So how do these technologies get me my LDAP information into a Intalio Business Process without having to add Netbeans, openESB, Glassfish to my toolbox.  Let me share.

Orbeon page-flow controller can be called from within your browser - http://localhost:8080/orbeon/ldap/rest.  If you want to filter your LDAP response, then add the parameter to your url - http://localhost:8080/orbeon/ldap/rest?cn={value}.  In the page-flow controller, construct a page element /ldap/rest and a default submission to extract the parameter from the url.  You have to create an xml file to hold these parameters.  The submission will call the ldap.xpl file which I first pass into a xsl processor to construct the filter dynamically for the ldap process.  I pass the xsl processor output to the ldap processor filter configuration.  You can build a test case and test it from your browser.  There is your RESTful LDAP service.

So how do you integrate this with Intalio.  Well, like I said, Intalio has a REST Connector.  Take your url statement above and using Intalio REST wizard create the RESTful service in intalio.  Drop the WSDL in your process and map your elements (input parameter and response message).  You are done.  Your process will call your end point url, which will call Orbeon XPL file and return the results to Intalio.  No need to install more servers and other tools.  I just use Orbeon and Intalio.

One note, the xml returned by Orbeon is in an empty namespace.  Intalio mapper will not recognize the variable without a namespace.  So, I had to add one more layer of transformation within the Orbeon XPL file.  After the LDAP response is returned, I pass this output to one final XSL Processor and include a namespace in the root of the xsl - xmlns="http://example.com/rest".  Then when intalio gets the data, a namespace is present and you can map the results in your business process to send out emails.

Another tip is to use xsl within the process to pass html into the body of the email service so your clients get nicely formatted email messages.

If you would like assistance on integrating this solution into one of your projects contact me at http://BTMSoftwareSolutions.com.