Question

Basically I want to be able to generate a response from BPEL ODE engine with complex type that has an unbounded number of elements. The idea is very basic, I get a list of objects as an input then I do some filtering based on a certain category. Then I need to generate response based on the filtering, which might be more than one elements. But the BPEL copy assignment only allow one to one assignment. I already try using array but can't seem to assign to more than one element also. The snippets below is for both the input and the output.

        <complexType name="hospitalType">
        <sequence minOccurs="1" maxOccurs="unbounded">
          <element name="patients">
          <complexType>
            <sequence>
              <element name="patient" minOccurs="1" maxOccurs="unbounded">
                <complexType>
                  <sequence>
                    <element type="string" name="name"/>
                    <element type="date" name="dob"/>
                    <element type="byte" name="age"/>
                    <element type="string" name="status"/>
                  </sequence>
                  <attribute name="pid" type="ID"/>
                </complexType>
              </element>
            </sequence>
          </complexType>
        </element>

So far the following is what I tried

       <bpel:copy>
                <bpel:from part="payload" variable="input">

                            <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
                                <![CDATA[tns:patients/tns:patient[1]]]>
                            </bpel:query>
                        </bpel:from>
                <bpel:to part="inload" variable="output">

                            <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
                                <![CDATA[tns:patients/tns:patient]]>
                            </bpel:query>
                        </bpel:to>

        </bpel:copy>

I can't even do a simple assignment if the input has more than one element..

Was it helpful?

Solution

This is a limitation of WS-BPEL. The standards compliant way to achieve this is to run an XSL tranformation. See page 65 of the WS-BPEL specification. To make this a little easier, ODE provides a couple of XPath extensions that allow for appending or inserting elements into a list. See here for a list. An example of such an assign looks as follows:

<assign>
  <copy>
    <from>ode:insert-after($parent, $parent/child::node(), $siblings)</from>
    <to variable="parent"/>
  </copy>
</assign>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top