Saturday, March 16, 2024
Employees XSD and WSDL | oneway employee create wsdl
Monday, March 11, 2024
OIC - XSLT - Find out the sum of all the invoice lines where each line having quantity and price using Call template
Usecase: we have a source json file where we have multiple items or lines and in each line we have line quantity and price. We have to find out the total amount of all the lines in XSLT.
Source payload:
{
"gp_number" : "56826526",
"lineLevel" : [ {
"Qty" : "4.00",
"Rate" : "50.00"
}, {
"Qty" : "3.00",
"Rate" : "25.00"
} ]
}
Target Payload:
{
"gp_number" : "56826526",
"AmountCal_line" : [ {
"Qty" : "4.00",
"Rate" : "50.00",
"Amount" : "200.00"
}, {
"Qty" : "3.00",
"Rate" : "25.00",
"Amount" : "75.00"
} ],
"TotalAmount" : "275.00"
}
Xslt sample:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:template match="/rootElement">
<!-- Initialize sum variable -->
<xsl:variable name="totalSum">
<xsl:call-template name="calculateTotal">
<xsl:with-param name="items" select="items/item"/>
</xsl:call-template>
</xsl:variable>
<!-- Output the total sum -->
<xsl:value-of select="$totalSum"/>
</xsl:template>
<xsl:template name="calculateTotal">
<xsl:param name="items"/>
<xsl:param name="sum" select="0"/>
<!-- Check if there are more items to process -->
<xsl:choose>
<xsl:when test="$items">
<!-- Calculate quantity multiplied by rate for the current item -->
<xsl:variable name="itemTotal" select="$sum + $items[1]/qty * $items[1]/rate"/>
<!-- Recursively call the template for the next item -->
<xsl:call-template name="calculateTotal">
<xsl:with-param name="items" select="$items[position() > 1]"/>
<xsl:with-param name="sum" select="$itemTotal"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- Return the final sum when all items are processed -->
<xsl:value-of select="$sum"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Screenshots:
Monday, March 4, 2024
Sample Calculator WSDL
Sample Calculator WSDL:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:ns1="http://org.apache.axis2/xsd"
xmlns:ns="http://c.b.a"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
targetNamespace="http://c.b.a"> <wsdl:documentation>Calculator</wsdl:documentation> <wsdl:types> <xs:schema attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="http://c.b.a"> <xs:element name="add"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="n1" type="xs:int" /> <xs:element minOccurs="0" name="n2" type="xs:int" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="addResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="return" type="xs:int" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name="addRequest"> <wsdl:part name="parameters" element="ns:add" /> </wsdl:message> <wsdl:message name="addResponse"> <wsdl:part name="parameters" element="ns:addResponse" /> </wsdl:message> <wsdl:portType name="CalculatorPortType"> <wsdl:operation name="add"> <wsdl:input message="ns:addRequest" wsaw:Action="urn:add" /> <wsdl:output message="ns:addResponse" wsaw:Action="urn:addResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="CalculatorSoap11Binding" type="ns:CalculatorPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <wsdl:operation name="add"> <soap:operation soapAction="urn:add" style="document" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name="CalculatorSoap12Binding" type="ns:CalculatorPortType"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <wsdl:operation name="add"> <soap12:operation soapAction="urn:add" style="document" /> <wsdl:input> <soap12:body use="literal" /> </wsdl:input> <wsdl:output> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name="CalculatorHttpBinding" type="ns:CalculatorPortType"> <http:binding verb="POST" /> <wsdl:operation name="add"> <http:operation location="add" /> <wsdl:input> <mime:content type="text/xml" part="parameters" /> </wsdl:input> <wsdl:output> <mime:content type="text/xml" part="parameters" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="Calculator"> <wsdl:port name="CalculatorHttpsSoap11Endpoint" binding="ns:CalculatorSoap11Binding"> <soap:address location="https://<host>:<port>/services/Calculator.CalculatorHttpsSoap11Endpoint/" /> </wsdl:port> <wsdl:port name="CalculatorHttpSoap11Endpoint" binding="ns:CalculatorSoap11Binding"> <soap:address location="http://<host>:<port>/services/Calculator.CalculatorHttpSoap11Endpoint/" /> </wsdl:port> <wsdl:port name="CalculatorHttpSoap12Endpoint" binding="ns:CalculatorSoap12Binding"> <soap12:address location="http://<host>:<port>/services/Calculator.CalculatorHttpSoap12Endpoint/" /> </wsdl:port> <wsdl:port name="CalculatorHttpsSoap12Endpoint" binding="ns:CalculatorSoap12Binding"> <soap12:address location="https://<host>:<port>/services/Calculator.CalculatorHttpsSoap12Endpoint/" /> </wsdl:port> <wsdl:port name="CalculatorHttpsEndpoint" binding="ns:CalculatorHttpBinding"> <http:address location="https://<host>:<port>/services/Calculator.CalculatorHttpsEndpoint/" /> </wsdl:port> <wsdl:port name="CalculatorHttpEndpoint" binding="ns:CalculatorHttpBinding"> <http:address location="http://<host>:<port>/services/Calculator.CalculatorHttpEndpoint/" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
Online wsdl generator:
http://marin.jb.free.fr/wsdl/
Featured Post
11g to 12c OSB projects migration points
1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper: File⇾Import⇾Service Bus Resources⇾ Se...
-
Please find the following links for OIC hands on and relevant information: Oracle Integration Cloud Introduction | Benefits | Services offer...
-
What is Throttling: Throttling is termed as "regulate the flow". Oracle Service Bus has throttling feature and by using that f...
-
OIC interview Q & A: 1. FBDI approach with an example https://soalicious.blogspot.com/2022/02/oic-erp-supplier-bulk-import-and.html 2. O...