AnsweredAssumed Answered

Can I make an external SOAP call in a GEL script?

Question asked by Rob-BBT on Sep 14, 2017
Latest reply on Sep 15, 2017 by Rob-BBT

We are trying to make a SOAP request to our Workday system within a GEL script in which we get time off requests and then run a resource XOG to update the resource calendar.

 

The Workday request doesn't require authentication and we can make the request and get a response back in SoapUI without issue.

 

However when making the request within a GEL script, it doesn't look like it's even making the connection at all as we are not getting a return code back and the raw XML result is coming back as [#document: null].

 

Here is my gel script.  For now all we are trying to do is prove the connectivity to Workday and output the results in the log:

 

I've modified the Workday endpoint to strip out the actual domain name .

 

 

<gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:core="jelly:core"
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="jelly:sql"
xmlns:xog="http://www.niku.com/xog"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


<core:invokeStatic var="caConfigMngr" className="com.niku.union.config.ConfigurationManager" method="getInstance" />
<core:set var="XogUrl" value="${caConfigMngr.getProperties().getWebServer().getSchedulerUrl()}/niku/xog" />
<core:new className="com.niku.union.security.DefaultSecurityIdentifier" var="secId"/>
<core:invokeStatic className="com.niku.union.security.UserSessionControllerFactory" method="getInstance" var="userSessionCtrl"/>
<core:set value="${userSessionCtrl.init(username, secId)}" var="secId"/>
<core:set value="${secId.getUserName()}" var="XOGUsername"/>
<core:set value="${secId.getSessionId()}" var="sessionID"/>

<gel:log category="Workday" level="INFO">Starting process</gel:log>

<!-- Make call to Workday TIBCO Service -->

<gel:parameter default="http://WORKDAY_URL:81/TIBCO_HS_DEV/Processes/Services/v2.1/WorkdayService.serviceagent/WorkdayPortEndpoint1" var="wkURL" />

<soap:invoke endpoint="${wkURL}" var="wkResult">
<soap:message>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.tibco.com/schemas/HumanSystems/SharedResources/XSD/v2.1/Schema.xsd12">
<soapenv:Header/>
<soapenv:Body>
<sch:ClarityRequest>
<sch:FromDt>2017-09-01</sch:FromDt>
<sch:ToDt>2017-09-10</sch:ToDt>
<sch:Channel_Id>Clarity</sch:Channel_Id>
</sch:ClarityRequest>
</soapenv:Body>
</soapenv:Envelope>
</soap:message>
</soap:invoke>

<gel:log category="Workday" level="INFO">Raw Result: ${wkResult}"</gel:log>
<!-- Check to see if connection was successful -->

<gel:set asString="true" select="$wkResult/SOAP-ENV:Envelope/SOAP-ENV:Body/ns0:ClarityResponse/ns0:Status/ns0:ReturnDescription/text()" var="wkCnResult"/>

<core:choose>
<core:when test="${wkCnResult == 'Successful'}">
<gel:forEach select="$wkResult/SOAP-ENV:Envelope/SOAP-ENV:Body/ns0:ClarityResponse/ns0:GetTimeOffRequests" var="wkReqDetail">
<gel:log category="Workday" level="INFO"><gel:expr select="$wkReqDetail/ns0:Logon/text()"/></gel:log>
<gel:log category="Workday" level="INFO"><gel:expr select="$wkReqDetail/ns0:FirstName/text()"/></gel:log>
<gel:log category="Workday" level="INFO"><gel:expr select="$wkReqDetail/ns0:LastName/text()"/></gel:log>
<gel:log category="Workday" level="INFO"><gel:expr select="$wkReqDetail/ns0:TimeOffDt/text()"/></gel:log>
<core:set value="$wkReqDetail/ns0:TimeOffHrs/text()" var="wkHrs"/>
<core:if test="$wkHrs &gt; 4.01">
<gel:log>Work day = false. Hours: ${wkHrs}</gel:log>
</core:if>
<core:if test="$wkHrs &lt; 4.01">
<gel:log>Work day = true. Hours: ${wkHrs}</gel:log>
</core:if>
</gel:forEach>
</core:when>
<core:otherwise>
<gel:log category="Workday" level="INFO">Connection to Workday was unsuccessful. Result Code: ${wkCnResult}</gel:log>

</core:otherwise>
</core:choose>

</gel:script>

Outcomes