Issue has been solved.
Original Message:
Sent: Wed May 14, 2025 04:43 AM
From: Kumar .
Subject: Custom SOAP Error Handling in XSLT with Switch and Throw Policy
Dears,
I have the following setup to throw an error if the 'when' condition is met. However, the error is not being thrown by the throw policy, and the assembly flow continues to execute.
Test.xslt:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pay="http://test.com"
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:dp="http://www.datapower.com/extensions"
xmlns:dpconfig="http://www.datapower.com/param/config"
xmlns:a="http://www.w3.org/2005/08/addressing">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:variable name="iterationCount" select="count(//pay:BulkTransactionRq[pay:Amount])"/>
<xsl:variable name="bulkCount" select="number(//pay:BulkCount)"/>
<xsl:variable name="bulkAmount" select="number(//pay:BulkAmount)"/>
<xsl:variable name="totalAmount" select="sum(//pay:BulkTransactionRq/pay:Amount)"/>
<xsl:choose>
<xsl:when test="$iterationCount != $bulkCount">
<dp:set-variable name="'var://context/count/gwsErrorType'" value="'gwsCountMismatch'"/>
</xsl:when>
<xsl:when test="$totalAmount != $bulkAmount">
<dp:set-variable name="'var://context/amount/gwsErrorType'" value="'gwsAmountMismatch'"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Switch condition(configured with throw policy):
Case1: gwsErrorType = 'gwsAmountMismatch'
Case2: gwsErrorType = 'gwsCountMismatch'
Could you please advise on what might be going wrong or suggest the correct way to ensure the flow stops when the condition is met?
------------------------------
Kumar
Original Message:
Sent: Wed May 14, 2025 02:29 AM
From: Kumar .
Subject: Custom SOAP Error Handling in XSLT with Switch and Throw Policy
Dear Brendon,
1)
My requirement is to stop the assembly flow when the details in the incoming payload match the when
conditions, and to return a custom SOAP response written in XSLT. However, since there are other actions after the XSLT in the flow, even when the when
conditions are met, the flow is not stopping.
What I expect is to keep the main logic in my XSLT as it is.
If the when
condition fails, I want to set context variables, which I will then use as conditions in a switch
policy. Based on those conditions, I will configure a throw
policy with a status code and error message. But I have no idea how to set context variables to this logic to use it in switch policy as a condition.
Naturally, when the condition fails, the throw
policy will stop the assembly flow and return the error.
I will enable a catch
block to handle the error thrown by the throw
policy.
In the catch block, I will write an XSLT to return the customized SOAP response that I have already written in the .xsl as output.
I haven't completed my XSLT to match with my requirement but I have attached it please check.
2)
I thought .js was the better approach but it's giving error. Please find the attached .js and when I log I could see below in the logs.
Parsed XML object: Document { type: 'XML Node', nodeType: 9 }
Found Body Node: undefined
BulkPaymentRequestMessage not found in the XML body
------------------------------
Kumar
Original Message:
Sent: Tue May 13, 2025 07:15 PM
From: Brendon Stephens
Subject: Custom SOAP Error Handling in XSLT with Switch and Throw Policy
Please post XSLT snippets so we can review them.
------------------------------
Brendon Stephens
Original Message:
Sent: Tue May 13, 2025 03:57 PM
From: Kumar .
Subject: Custom SOAP Error Handling in XSLT with Switch and Throw Policy
Hello Everyone,
Can anyone help with your Inputs?
------------------------------
Kumar
Original Message:
Sent: Tue May 13, 2025 06:07 AM
From: Kumar .
Subject: Custom SOAP Error Handling in XSLT with Switch and Throw Policy
Dears,
Could anyone tell me if what I've mentioned can be achieved, or suggest any alternative approaches if available to stop the assembly flow and throw customized soap message with error details?
------------------------------
Kumar
Original Message:
Sent: Tue May 13, 2025 02:31 AM
From: Kumar .
Subject: Custom SOAP Error Handling in XSLT with Switch and Throw Policy
Dears,
I have two conditions in my XSLT, and if either of them is met, I need to stop the assembly flow and generate an error message with a customized SOAP structure. Can this be achieved using a switch and throw policy? The request type is SOAP.
------------------------------
Kumar
------------------------------