Monday, April 29, 2019

Connecting to Workday using Mule HTTP Connector


In this article, we will see how we can connect to Workday HCM (Human Capital Management) a SAAS system using Mule HTTP Connector.

There are multiple ways to connect to Workday HCM like (1) Using MuleSoft Workday Connector (It’s a select connector) (2) Using custom Java code – JAXP (Java API for XML Processing) (3) HTTP connector.



Problem with option 1 is, we need to have an enterprise license to use MuleSoft Workday Connector and issue with option 2 is no point in using custom java code (JAXP) while using Mule.

Requirement:
Connect to workday at a specific time of the day to download employee data, transform and enrich it to CSV file and send it to external systems.

Drag and drop poll scope and setup cron expression to kick start mule flow.




Use Until Successful scope and drop HTTP connector inside it. This will help with reconnection attempts. Use basic authentication for connecting to Workday. Using OAuth2 will be a better option.



 






When the payload is huge (like 20 MB or more), then below 2 attributes are important, because we need the connection to stay open & active for a longer time (say 1 to 3 mins) and the HTTP Connector should wait for the large payload to fully download before the control is passed on to the next mule message processor in the flow.


https.connection.idle.timeout
The number of milliseconds that a connection can remain idle before it is closed. The value of this attribute is only used when persistent connections are enabled.

https.response.timeout
The maximum time that the request element will block the execution of the flow waiting for the HTTP response. If this value is not present, the default response timeout from the Mule configuration will be used.

Since the response from Workday is XML file (DOM Object), we use Object to ByteArray transformer. We then use a Message filter (Expression filter inside message filter to specify XPATH3 expression) to filter out null/empty payload.



unaccepted-messages-handler-flow

When the expression is not satisfied, in this case, the payload should not be null, then the control is sent to another sub-flow where we print a suitable log message.




No comments:

Post a Comment