14 Replies Latest reply on Jan 5, 2011 11:45 AM by Gary Brown

    Problem with using arrays in BPEL

    Alexej Laske Newbie
      Hi all,
      I have a problem to use arrays in BPEL. In the past I used GlassFish as App Server with integrated bpel service engine. It was very easy to use arrays in BPELs on GlassFish. Now on JBoss with RiftSaw I have troubles to do that in similar way. For example I try to prepare in BPEL a call for webservice method to create an Item that should have two or more InputFields with different names and values.
      Initial I defined the createItemIn variable:
      <bpel:variable name="createItemIn" messageType="ns1:Integrity_2009_createItem"/>
      Then I "preinit" this var:
                  <bpel:copy insertMissingToData="yes">
                      <bpel:from>
                        <bpel:literal>
                        <ns1:createItem xmlns:ns1="http://webservice.mks.com/2009/Integrity">
                        <arg0 transactionId="" Type="" xmlns="">                                                                                                                    
                        </arg0>
                        </ns1:createItem>
                        </bpel:literal>
                      </bpel:from>
                      <bpel:to variable="createItemIn" part="createItem"/>
                  </bpel:copy>
      In the next step I try to set values for createItemIn that should been of Type "DemoTypeA" and have two ItemFields named "PartnerID" and "Summary":
      <bpel:assign name="Ass_ItemType">
      <bpel:copy insertMissingToData="yes">
      <bpel:from><bpel:literal>DemoTypeA</bpel:literal></bpel:from>
      <bpel:to>$createItemIn.createItem/arg0/@Type</bpel:to>
      </bpel:copy>
      </bpel:assign>
      <bpel:assign name="Ass_PartnerID">      
      <bpel:copy insertMissingToData="yes">
      <bpel:from><bpel:literal>PartnerID</bpel:literal></bpel:from>
      <bpel:to>$createItemIn.createItem/arg0/int:ItemField[1]/@Name</bpel:to>
      </bpel:copy>
      <bpel:copy insertMissingToData="yes">
      <bpel:from>12</bpel:from>
      <bpel:to>$createItemIn.createItem/arg0/int:ItemField[1]/int:integer</bpel:to>
      </bpel:copy>
      </bpel:assign>
      <bpel:assign name="Ass_Summary">      
      <bpel:copy insertMissingToData="yes">
      <bpel:from><bpel:literal>Summary</bpel:literal></bpel:from>
      <bpel:to>$createItemIn.createItem/arg0/int:ItemField[2]/@Name</bpel:to>
      </bpel:copy>
      <bpel:copy insertMissingToData="yes">
      <bpel:from><bpel:literal>harcoded BPEL Summary</bpel:literal></bpel:from>
      <bpel:to>$createItemIn.createItem/arg0/int:ItemField[2]/int:shorttext</bpel:to>
      </bpel:copy>
      </bpel:assign>
      In GlassFish BPELs does it work without any problems, but not in RiftSaw on JBoss. I believe the problem is in arrays ItemField[x], because if I define a createItemIn with only one ItemField without array bracket [] it works fine! But I can not accept this, because I have to create Items that contains several ItemFields.
      Is there an other option how I can use arrays in RiftSaw BPELs?
      Thanks in advance!
        • 1. Re: Problem with using arrays in BPEL
          Gary Brown Master

          You may want to look at some of the extension xpath functions provided by ODE (http://ode.apache.org/xpath-extensions.html).

           

          If there is a specific case that you think should work, then best to provide a simple test case and create a jira. We can then see if there is something we can do in RiftSaw, and if not, delegate the issue to the ODE project.

           

          Regards

          Gary

          • 2. Re: Problem with using arrays in BPEL
            Alexej Laske Newbie

            Hi Gary,

             

            thank you for your response. I get my code working without using arrays, in that way:

             

             

            <bpel:assign name="Ass_ItemFields">
            <bpel:copy insertMissingToData="yes">
                            <bpel:from>
                                  <bpel:literal>
                                       <ns1:createItem xmlns:ns1="http://webservice.mks.com/2009/Integrity">
                                            <arg0 transactionId="" Type="" xmlns="">
                                                 <int:ItemField Name="PartnerID">
                                                      <int:integer>1000</int:integer>
                                                 </int:ItemField>
                                                 <int:ItemField Name="Summary">
                                                      <int:shorttext>foo bar</int:shorttext>
                                                 </int:ItemField>                                                                                                                                                                                                                                                             
                                            </arg0>
                                       </ns1:createItem>
                                  </bpel:literal>
                            </bpel:from>
                            <bpel:to variable="createItemIn" part="createItem"/>
                        </bpel:copy>
            </bpel:assign>
            <bpel:assign name="Ass_ItemType">
                        <bpel:copy insertMissingToData="yes">
            <bpel:from><bpel:literal>DemoTypeA</bpel:literal></bpel:from>
            <bpel:to>$createItemIn.createItem/arg0/@Type</bpel:to>
            </bpel:copy>
            </bpel:assign>
            Instead of array I use createItem structure to name ItemFields and put their values in that. It has more code, is not as elegant as using arrays, it works but the problem now is, in that way I can only put hardcoded values to ItemFields values and not values of variables (e.g. $var_xyz), because of <bpel:literal>.
            I try tomorrow again, maybe I get more success.
            • 3. Re: Problem with using arrays in BPEL
              Gary Brown Master

              You should be able to also use the same approach that you have used, to set the value of the Type attribute, for the text values aswell.

              • 4. Re: Problem with using arrays in BPEL
                Igor JStarter Novice

                Could someone PLEASE provide an example of copying one array to another ?

                 

                If made a process with an arrayofstrings on the input and an arrayofstrings as output. I just want to copy it.

                First I tried to do it without the xpath-extensions. When copying just one field, it works. 2 fields don't work any more.

                 

                So... it must be with xpath extensions... Did someone manage to do that with this createItem ?

                • 5. Re: Problem with using arrays in BPEL
                  Jeff Yu Master

                  we had a jira request for this. https://issues.jboss.org/browse/RIFTSAW-219, we target it for 2.3.0 release now, if you'd like it to be in earlier release, please vote for it.

                   

                  Regards

                  Jeff

                  • 6. Re: Problem with using arrays in BPEL
                    Igor JStarter Novice

                    But looks like people made it work with the doXslTransformation ?

                    • 7. Re: Problem with using arrays in BPEL
                      Igor JStarter Novice

                      No way to copy to an array ???

                       

                      Must wait for RiftSaw 2.3 ?

                      • 8. Re: Problem with using arrays in BPEL
                        Gary Brown Master

                        Hi Igor

                         

                        Sorry for the late response - just back from vacation.

                         

                        There is unlikely to be any change in riftsaw to support arrays in BPEL. The only impact this has on riftsaw is the inclusion of an example. As we are approaching the point where we will release version 2.2.0.Final, it was decided to move all of the issues unlikely to make it into that release to version 2.3.

                         

                        However if you have luck sorting out an example, as I know you have been communicating with the ODE community, then we would appreciate the contribution - and if before the end of the month, then it may make it into 2.2.0.Final.

                         

                        The problem is that array support does not seem to be have been considered properly in BPEL - hence having to potentially deal with it by transforming a source doc, which appears a bit extreme. I have not found any simple ways to do it.

                         

                        Regards

                        Gary

                        • 9. Re: Problem with using arrays in BPEL
                          Igor JStarter Novice

                          It works... but on my specific project I have a problem and don't know why doesn't it copy to the array...

                          MY BPEL input is specified as:

                          <element name="ArraybRequest">
                                          <complexType>
                                              <sequence>
                                                  <element name="arrSubscriber">
                                                      <complexType>
                                                          <sequence>
                                                              <element name="theusers"  minOccurs="1" maxOccurs="unbounded">
                                                                  <complexType>
                                                                      <sequence>
                                                                          <element name="sPhone" type="string" minOccurs="0"/>
                                                                          <element name="sFirstName" type="string" minOccurs="0"/>
                                                                          <element name="sLastName" type="string" minOccurs="0"/>
                                                                          <element name="calDateOfBirth" type="dateTime" minOccurs="0"/>
                                                                          <element name="iPostCode" type="int" minOccurs="0"/>
                                                                          <element name="sAddress" type="string" minOccurs="0"/>
                                                                          <element name="bSendSMS" type="boolean" minOccurs="0"/>
                                                                          <element name="sMultimediaIP" type="string" minOccurs="0"/>
                                                                          <element name="sDomoticIP" type="string" minOccurs="0"/>
                                                                      </sequence>

                           

                          I'm able to get the theUsers array length with:

                          <bpel:copy>
                                          <bpel:from>              
                                              <![CDATA[count($input.payload/tns:arrSubscriber/tns:theusers)]]>
                                          </bpel:from>
                                          <bpel:to variable="itemCount"></bpel:to>
                                      </bpel:copy>

                           

                          I my while seuquence I can copy the multimediaIP of every user with:

                          <bpel:copy>
                                              <bpel:from>               
                                                  <![CDATA[$input.payload/tns:arrSubscriber/tns:theusers[round($iterator)]/tns:sMultimediaIP]]>
                                              </bpel:from>
                                              <bpel:to variable="y"></bpel:to>
                                          </bpel:copy>

                           

                          And that works... The variable y is always filled with the multimediaIP of the user[iterator].

                          But I don't know why my BPEL doesn't copy from variable y to the array of the external web service, which i want to call... Always empty...

                           

                          <bpel:copy>
                                             
                                                  <bpel:from expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
                                                      <![CDATA[ode:insert-as-first-into($ArraysLinkRequest.parameters/tns4:args0, $y)]]>
                                                  </bpel:from>
                                                  <bpel:to part="parameters" variable="ArraysLinkRequest">
                                                      <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns4:args0]]></bpel:query>
                                                  </bpel:to>
                                              </bpel:copy>

                           

                          The ArraysLinkRequest is defined as:

                          <xs:element maxOccurs="unbounded" minOccurs="0" name="args0" nillable="true" type="xs:string"/> and is tns4 in my BPEL...

                           

                          Any idea what's wrong with the last copy to the tns4:args0 ?

                           

                          BR, Igor

                          • 10. Re: Problem with using arrays in BPEL
                            Gary Brown Master

                            Can't see anything obvious. Have you tried enabling trace level logging for org.apache.ode, as you might see relevant information in the log concerning each copy operation.

                             

                            The only other thing is if you could put together a simple 'quickstart' example that demonstrates the problem and submit it, might be easier to take a look.

                             

                            Regards

                            Gary

                            • 11. Re: Problem with using arrays in BPEL
                              Igor JStarter Novice

                              How to enable trace level logging for org.apache.ode ?

                               

                              Quickstart? How can I post it ?

                              What is more... my external service is an .aar. So... the one who would like to try needs to install axis2 too...

                              • 12. Re: Problem with using arrays in BPEL
                                Igor JStarter Novice

                                I see that i get an warning

                                Map access not implemented

                                 

                                for every element of my users array...  Could that be the problem of empty array elements ?

                                • 13. Re: Problem with using arrays in BPEL
                                  Gary Brown Master

                                  Igor JStarter wrote:

                                   

                                  I see that i get an warning

                                  Map access not implemented

                                   

                                  for every element of my users array...  Could that be the problem of empty array elements ?

                                   

                                  No, this is unrelated - see http://community.jboss.org/thread/160679?tstart=0

                                  • 14. Re: Problem with using arrays in BPEL
                                    Gary Brown Master

                                    Igor JStarter wrote:

                                     

                                    How to enable trace level logging for org.apache.ode ?

                                     

                                    Quickstart? How can I post it ?

                                    What is more... my external service is an .aar. So... the one who would like to try needs to install axis2 too...

                                    Enable trace logging by configuring the $jboss/server/default/conf/jboss-log4j.xml with the following entry:

                                     

                                    <category name="org.apache.ode">
                                          <priority value="DEBUG"/>
                                       </category>

                                     

                                    after the 'Limit categories' comment. A value of 'TRACE' should also work.

                                     

                                    In terms of the example, that does make it more difficult