Contact Us 1-800-596-4880

Workday Connector 14.1 Examples - Mule 4

Anypoint Connector for Workday (Workday Connector) provides two financial management services examples that enable you to see how to configure Workday Connector using Anypoint Studio:

Before You Begin

You must have:

  • Access to Workday

  • Your Workday username, password, and tenant name

Add a Fund to the Workday Financial Management Service (Studio Example)

This example uses the Invoke operation to insert a fund in the Workday financial management service.

Configure HTTP Listener

Configure HTTP Listener to initiate a Mule flow when a call is made to the / account path on localhost, port 8081.

This example uses variables for some field values. You can either:

  • Replace the variables with their values in the code.

  • Provide the values for each variable in a properties file and then refer to that file from the connector configuration.

If you don’t know how to use a properties file, see Configuring Property Placeholders.

To configure HTTP Listener:

  1. Create a new Mule project in Studio.

  2. In the Mule Palette view, search for http and select the Listener operation:

    Select the Listener operation in the Mule Palette view.

    Select the Listener operation

  3. Drag the Listener operation onto the canvas.

  4. In the Listener configuration, click + next to the Connector configuration field to add a global element.

  5. Click OK to accept the defaults.

  6. Set the Path field to /:

    Listener configuration
    Figure 1. Set the Path field in the Listener configuration.

Add a Transform Message Component to Attach the Metadata

To add and configure a Transform Message component:

  1. In the Mule Palette view, search for transform and select Transform Message:

    Select the Transform Message component
    Figure 2. Select Transform Message in the Mule Palette view.
  2. Drag the Transform Message component onto the canvas, to the right of the Listener component.

  3. In the Transform Message configuration, overlay the brackets in the Output section with this XML:

    %dw 2.0
    output application/xml
    ns ns0 urn:com.workday/bsvc
    ---
    {
      ns0#Put_Fund_Request @(ns0#Add_Only: true, ns0#version: "v36.0"): {
        ns0#Fund_Data: {
          ns0#Fund_Name: "I.M.F",
          ns0#Fund_Type_Reference: {
            ns0#ID @(ns0#'type': 'Fund_Type_ID'): "FUND_TYPE-6-3"
          }
        }
      }
    }

The following XML shows sample input to the Transform Message component

<ns0:Put_Fund_Request xmlns:ns0="urn:com.workday/bsvc" Add_Only="true" version="v36.0">
  <ns0:Fund_Data>
    <ns0:Fund_Name>I.M.F</ns0:Fund_Name>
    <ns0:Fund_Type_Reference>
      <ns0:ID type="Fund_Type_ID">FUND_TYPE-6-3</ns0:ID>
    </ns0:Fund_Type_Reference>
  </ns0:Fund_Data>
</ns0:Put_Fund_Request>

The following screenshot shows the corresponding output, as it appears in the Output section of the Transform Message configuration:

Transform Message output
Figure 3. Output in the Transform Message configuration

Add and Configure the Financial Management Operation

  1. In the Mule Palette view, search for workday and select the Financial management operation.

  2. Drag the Financial management operation onto the canvas, to the right of the Transform Message component.

  3. In the Financial management configuration, click + next to the Connector configuration field to add a global element.

  4. Configure the global element as follows:

    • Configuration Name: My_Workday_Connection

    • Connection: Basic authentication api

    • Password: ${workday.password}

    • Host Name: Leave the default, impl-cc.workday.com

    • Tenant Name: ${workday.tenantName}

    • Username: ${workday.userName}

  5. Click Test Connection to ensure your username, password, and tenant name are correct.

  6. Click OK.

  7. In the properties window, select Put_Fund in the Operation field.

Add a Logger Component to Display the Response in the Mule Console

  1. In the Mule Palette view, search for logger and select Logger (Core).

  2. Drag the Logger component onto the canvas, to the right of the Financial management component.

  3. Configure the following fields:

    Field Value

    Display Name

    Enter Log Response.

    Message

    Enter `#[payload]`.

    Level

    Leave the default, INFO.

  4. Save the project.

  5. Test the app by sending a request to / on port 8081.

  6. You will receive an XML response similar to this one:

<wd:Put_Fund_Response xmlns:wd="urn:com.workday/bsvc" wd:version="v36.0">
    <wd:Fund_Reference wd:Descriptor="I.M.F">
        <wd:ID wd:type="WID">THE_WID_ID_NUMBER</wd:ID>
        <wd:ID wd:type="Fund_ID">FUND-6-399</wd:ID>
    </wd:Fund_Reference>
</wd:Put_Fund_Response>

XML for the Financial Management Example

Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:

?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns:workday="http://www.mulesoft.org/schema/mule/workday"
	xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/workday http://www.mulesoft.org/schema/mule/workday/current/mule-workday.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<workday:config name="My_Workday_Connection" doc:name="Workday Config" >
		<workday:basic-authentication-api-connection password="${workday.password}" tenantName="${workday.tenantName}" userName="${workday.userName}" />
	</workday:config>
	<http:listener-config name="HTTP_Listener_config1" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<workday:config name="My_Workday-Connection" doc:name="Workday Config" >
		<workday:basic-authentication-api-connection password="${workday.password}" tenantName="${workday.tenantName}" userName="${workday.userName}" />
	</workday:config>
	<flow name="workday-13-test-exampleFlow" >
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config1" path="/"/>
		<ee:transform doc:name="Transform Message" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
ns ns0 urn:com.workday/bsvc
---
{
  ns0#Put_Fund_Request @(ns0#Add_Only: true, ns0#version: "v36.0"): {
    ns0#Fund_Data: {
      ns0#Fund_Name: "I.M.F",
      ns0#Fund_Type_Reference: {
        ns0#ID @(ns0#'type': 'Fund_Type_ID'): "FUND_TYPE-6-3"
      }
    }
  }
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<workday:financial-management doc:name="Financial management" config-ref="My_Workday-Connection"/>
		<logger level="INFO" doc:name="Log Response"  message="#[payload]"/>
	</flow>
</mule>
View on GitHub