You can now map collections within your SOAP request to your application. If you want your collection to be displayed for certain iterations, you can also add a for loop
to your SOAP contract. IDE now supports n level nested collections as a part of the request template.
An example of a single level collection is as follows:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style"> <soapenv:Header/> <soapenv:Body> <urn:ZFmmmGoodsReceiptKony> <!--Optional:--> <IGrCreate> <GRHeader> <HId>$HId</HId> <HTime>$HTime</HTime> <HUser>$HUser</HUser> <!--Add the for loop for Zero or more repetitions:--> #foreach $items <item> <Bldat>$Bldat</Bldat> <Budat>$Budat</Budat> <Mtsnr>$Mtsnr</Mtsnr> <Usnam>$Usnam</Usnam> <PoNumber>$PoNumber</PoNumber> <PoItem>$PoItem</PoItem> <PoUnit>$PoUnit</PoUnit> <QuantityRec>$QuantityRec</QuantityRec> <UnloadPoint>$UnloadPoint</UnloadPoint> <Xsaut>$Xsaut</Xsaut> </item> #end <!--end of loop:--> </GRHeader> </IGrCreate> </urn:ZFmmmGoodsReceiptKony> </soapenv:Body> </soapenv:Envelope>
You can similarly have multiple nested collections and you can define a for loop for each of the nested collections. Ensure that each of the for loop has a unique identifier name. For example #foreach $<uniqueidentifier>
. Since Kony Studio parses the items and creates a service definition template using end of line logic for each for statement till for end of loop.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style"> <soapenv:Header/> <soapenv:Body> <urn:ZFmmmGoodsReceiptKony> <!--Optional:--> <IGrCreate> <GRHeader> <HId>$HId</HId> <HTime>$HTime</HTime> <HUser>$HUser</HUser> <!--Zero or more repetitions:--> #foreach $items <item> <Bldat>$Bldat</Bldat> <Budat>$Budat</Budat> <Serialno> <!--Zero or more repetitions:--> #foreach $SerialNo <item> <Gernr>$Gernr</Gernr> <UnloadPoint>$UnloadPoint</UnloadPoint> #foreach $test <XXX>$a</XXX> #end </item> #end </Serialno> </item> #end </GRHeader> </IGrCreate> </urn:ZFmmmGoodsReceiptKony> </soapenv:Body> </soapenv:Envelope>
Scenario 1: If the input value for an element is not provided, you can include an exclamation mark "!" after the "$" (for example, <Bldat>$!Bldat</Bldat>
) to generate a collection that includes null value. For example: <Bldat></Bldat>
To avoid this empty <Bldat></Bladat> tag, you can use the following if condition statement:
#if ($Bldat) <Bldat>$!Bldat</Bldat> #end
Scenario 2: If a Key is missing in the input parameter, write the template in the following manner and past it in the request tab:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style"> <soapenv:Header/> <soapenv:Body> <urn:ZFmmmGoodsReceiptKony> <!--Optional:--> <IGrCreate> <GRHeader> <HId>$HId</HId> <HTime>$HTime</HTime> <HUser>$HUser</HUser> <!--Zero or more repetitions:--> #foreach ($rec in $items.records) #set( $Budat = $rec.getParam("Budat").getEscapeXMLValue()) #set( $Bldat = $rec.getParam("Bldat").getEscapeXMLValue()) #set( $SerialNo = $rec.getDatasetById("SerialNo")) <item> <Bldat>$Bldat</Bldat> <Budat>$Budat</Budat> <Serialno> <!--Zero or more repetitions:--> #foreach ($rec in $SerialNo.records) #set( $Gernr = $rec.getParam("Gernr").getEscapeXMLValue()) #set( $UnloadPoint = $rec.getParam("UnloadPoint").getEscapeXMLValue()) <item> <Gernr>$Gernr</Gernr> <UnloadPoint>$UnloadPoint</UnloadPoint> </item> #end </Serialno> </item> #end </GRHeader> </IGrCreate> </urn:ZFmmmGoodsReceiptKony> </soapenv:Body> </soapenv:Envelope>
After you have structured your xml, do the following:
Test Value is the value of the parameter that is used for testing the service. The test value for a collection could be of the form:
[{"Bldat":"123","Budat":"adf","SerialNo":[{"Gernr":"AAAA","UnloadPoint":"adadad","test":[{a:abc},{a:def}]} ,{"Gernr":"BBBB","UnloadPoint":"adadad","test":[{a:abc},{a:def}]}]}]
For an item whose value whose value is empty specify it as [].
You can now map collections within your JSON request to your application.
If you want your collection to be displayed for certain iterations, you can also add a for loop
to your JSON input.
Kony Fabric Console supports multilevel (N level) nested collections as part of the request template.
Example of a simple single level collection is as follows:
{ "users": [ #foreach $users #if($velocityCount!=1) , #end {"firstname": "$firstname","lastname":"$lastname"} #end ] }
Note that you have to change the datatype to collection in Kony Fabric Console for the added input parameter. To test, pass a simple single level JSON.
For example:
[{ "firstname": "Sam", "lastname": "Tim" }, { "firstname": "Jim","lastname": "Jerry" }]
Note: For nested collections, please go through the SOAP documentation for collection.
You can now map collections within your XML request to your application.
If you want your collection to be displayed for certain iterations, you can also add a for loop
to your XML input.
Kony Fabric Console supports multilevel (N level) nested collections as part of the request template.
Example of a simple single level collection is as follows:
#foreach $items <item> <Bldat>$Bldat</Bldat> <Budat>$Budat</Budat> <Mtsnr>$Mtsnr</Mtsnr> </item> #end
And you can pass an input collection with a test value:
[{"Bldat":"123","Budat":"adf","Mtsnr":"dsd"},{"Bldat":"234","Budat":"ffg","Mtsnr":"aff"},{"Bldat":"677","Budat":"fdf","Mtsnr":"jft"}]
Rev | Author | Edits |
7.1 | SD | SD |
Copyright © 2020 Kony, Inc. All rights reserved. |