Few days ago, I was facing an issue where I wanted to generate a request for a webservice in a BPEL. This request had an element of type list. This Element had multiple children of type string.
I couldn't find a straight example to achieve this anywhere. So I hope my post will help you resolve the same issue!
Let's assume that you have a list of property which is called extraProps. Each property has two child 1) name and 2) value.
You want to populate your inputVariable with 3 property in extraProps. Part of your request would look like following:
<extraProps>
To achieve this, you can do following:
1) Start with first entry in the list.
I couldn't find a straight example to achieve this anywhere. So I hope my post will help you resolve the same issue!
Let's assume that you have a list of property which is called extraProps. Each property has two child 1) name and 2) value.
You want to populate your inputVariable with 3 property in extraProps. Part of your request would look like following:
<extraProps>
<property>
<name>xStorageRule</name>
<value>default</value>
</property>
<property>
<name>xInvoiceType</name>
<value>type1</value>
</property>
<property>
<name>xRunID</name>
<value>runid_5</value>
</property>
</extraProps>
To achieve this, you can do following:
1) Start with first entry in the list.
Copy the values (xStorageRule and default) using Edit Assign editor of JDeveloper as if they are not part of list. See the image below.
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property/ns6:name"/>
</copy>
<copy>
<from expression="'default'"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property/ns6:value"/>
</copy>
<bpelx:append>
<bpelx:from variable="checkInUniversal_InputVariable"
part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[1]"/>
<bpelx:to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps"/>
</bpelx:append>
<bpelx:append>
<bpelx:from variable="checkInUniversal_InputVariable"
part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[1]"/>
<bpelx:to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps"/>
</bpelx:append>
After this step you already have list of property (3 elements) in extraProps, but all 3 of they have same name-value pair. So in the next step, we will overwrite the name-value pair for 2nd and 3rd element in the list.
3) Overwrite the name-value pairs with correct values.
Using the "Edit Assign" Editor, this steps looks little tricky. Once assigning the values you manually need to change the "To XPath" to specify correct element in the array. See the image below.
As you can see, I have overwritten 2nd and 3rd element of extraProps in this step with the correct values.
The source code for this step would look like:
<copy>
<from expression="'xInvoiceType'"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[2]/ns6:name"/>
</copy>
<copy>
<from variable="invoiceType"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[2]/ns6:value"/>
</copy>
<copy>
<from expression="'xRunID'"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[3]/ns6:name"/>
</copy>
<copy>
<from variable="billRunId"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[3]/ns6:value"/>
</copy>
And that's the end of the post! If you find this helpful, please live a comment. Thank you.
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property/ns6:name"/>
</copy>
<copy>
<from expression="'default'"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property/ns6:value"/>
</copy>
2) Append (add) next elements (property) into the list (extraProps)
Now instead of Copy function use Append function. I used the property populated in the last step to append 2nd and 3rd element in the list. See the image below.
The source code for this will look like:
<bpelx:append>
<bpelx:from variable="checkInUniversal_InputVariable"
part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[1]"/>
<bpelx:to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps"/>
</bpelx:append>
<bpelx:append>
<bpelx:from variable="checkInUniversal_InputVariable"
part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[1]"/>
<bpelx:to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps"/>
</bpelx:append>
After this step you already have list of property (3 elements) in extraProps, but all 3 of they have same name-value pair. So in the next step, we will overwrite the name-value pair for 2nd and 3rd element in the list.
3) Overwrite the name-value pairs with correct values.
Using the "Edit Assign" Editor, this steps looks little tricky. Once assigning the values you manually need to change the "To XPath" to specify correct element in the array. See the image below.
As you can see, I have overwritten 2nd and 3rd element of extraProps in this step with the correct values.
The source code for this step would look like:
<copy>
<from expression="'xInvoiceType'"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[2]/ns6:name"/>
</copy>
<copy>
<from variable="invoiceType"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[2]/ns6:value"/>
</copy>
<copy>
<from expression="'xRunID'"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[3]/ns6:name"/>
</copy>
<copy>
<from variable="billRunId"/>
<to variable="checkInUniversal_InputVariable" part="payload"
query="/ns6:CheckInUniversal/ns6:extraProps/ns6:property[3]/ns6:value"/>
</copy>
And that's the end of the post! If you find this helpful, please live a comment. Thank you.