How to Statically Index into an XML Data Sequence That Uses Arrays

Manipulating XML Data in a BPEL Process 6-47 bpelx:from variable=request part=strArray query=strArrayJavaLangstring1 bpelx:to variable=request part=strArray query=strArray bpelx:append bpws:assign 3. Import the following namespace in your WSDL file. Oracle JDeveloper does not understand the SOAP-ENC tag if the import statement is missing in the WSDL schema element. xs:import namespace=http:schemas.xmlsoap.orgsoapencoding

6.19.2.1 SOAP-Encoded Arrays in BPEL 2.0

SOAP-encoded arrays are supported in BPEL projects that use version 2.0 of the BPEL specification. Example 6–88 shows a sample assign activity with a SOAP-encoded array in a BPEL 2.0 project. Example 6–88 SOAP-Encoded Array in an Assign Activity in BPEL 2.0 assign name=Assign_1 copy frominputVariable.payloadfrom toInvoke_1_echoArray_InputVariable.strArrayJavaLangstring[1]to copy extensionAssignOperation bpelx:append bpelx:from variable=Invoke_1_echoArray_InputVariable part=strArray bpelx:query JavaLangstring[1] bpelx:query bpelx:from bpelx:to variable=Invoke_1_echoArray_InputVariable part=strArray bpelx:to bpelx:append extensionAssignOperation assign Example 6–89 shows a sample invoke activity with a SOAP-encoded array in a BPEL 2.0 project. Example 6–89 SOAP-Encoded Array in an Invoke Activity in BPEL 2.0 invoke name=Invoke1 partnerLink=FileOut portType=ns3:Write_ptt operation=Write bpelx:invokeAsDetail=no toParts toPart part=body fromVariable=ArrayVariable toParts invoke

6.19.3 How to Determine Sequence Size

If you must know the runtime size of a data sequence that is, the number of nodes or data items in the sequence, you can get it by using the combination of the XPath built-in count function and the BPEL built-in getVariableData function. 6-48 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite The code in Example 6–90 calculates the number of elements in the item sequence and assigns it to the integer variable lineItemSize. Example 6–90 Sequence Size Determination assign copy from expression=countbpws:getVariableData’outpoint’, ’payload’, p:invoicep:lineItemsp:item to variable=lineItemSize copy assign

6.19.4 How to Dynamically Index by Applying a Trailing XPath to an Expression

Often a dynamic value is needed to index into a data sequence; that is, you must get the nth node out of a sequence, where the value of n is defined at runtime. This section covers the methods for dynamically indexing by applying a trailing XPath into expressions.

6.19.4.1 Applying a Trailing XPath to the Result of getVariableData

The dynamic indexing method shown in Example 6–91 applies a trailing XPath to the result of bwps:getVariableData, instead of using an XPath as the last argument of bpws:getVariableData. The trailing XPath references to an integer-based index variable within the position predicate that is, [...]. Example 6–91 Dynamic Indexing variable name=idx type=xsd:integer ... assign copy from expression=bpws:getVariableDatainput,payload p:line-item[bpws:getVariableDataidx]p:line-total to variable=lineTotalVar copy assign Assume at runtime that the idx integer variable holds 2 as its value. The preceding expression within the from is equivalent to that shown in Example 6–92 . Example 6–92 Equivalent Format from expression=bpws:getVariableDatainput,payload p:line-item[2]p:line-total There are some subtle XPath usage differences, when an XPath used trailing behind the bwps:getVariableData function is compared with the one used inside the function. Using the same example where payload is the message part of element p:invoice, if the XPath is used within the getVariableData function, the root element name p:invoice must be specified at the beginning of the XPath. Example 6–93 provides details. Example 6–93 Root Element Name Specification bpws:getVariableDatainput, payload,