Split an XML File and invoke a Web Serivce for each splits using an XSLT
900257Jan 18 2012 — edited Feb 26 2020Hi,
We Have a requirement to Split an incoming XML File into chunks based on a child element and hit the target Web Service for each and every split ( i.e no of splits = no of hits on WebService).
Currently, the incoming XML file is getting splitted and gets appended to the SAME Payload and the WebService is hitted only once with the entire Payload.
Is it possible to invoke a WebService within a XSLT ?
Please find below the XSLT code used to split the file in chunks of 3
<xsl:param name="pItemsNumber" select="3"/>
<xsl:template match="@*|node()">
<xsl:choose>
<xsl:when test="count(Batch/Item) > 4">
<ItemMaintenance>
<xsl:for-each-group select="Batch/Item"
group-adjacent="(position()-1) idiv $pItemsNumber">
<xsl:result-document href="ItemsMatch\{current-grouping-key()}.xml">
<ItemMaintenance>
<xsl:copy-of select="current-group()"/>
</ItemMaintenance>
</xsl:result-document>
</xsl:for-each-group>
</ItemMaintenance>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>