Oracle SOA 11g – BPEL 1.1 to BPEL 2.0 Upgrade

In my current project we were using BPEL 1.1 processes. Then SOA Suite 11gR1PS3 came along and gave use BPEL 2.0. So, we decided to start upgrading our already build BPEL 1.1 processes to version 2.0 for making it a standard implementation considering future enhancements.

As there are no BPEL 2.0 upgrade tools we had basically two options. The first was to complete rebuild all our processes. Not a very good option to redo all the work. The second option was to manually upgrade the BPEL 1.1 definitions to 2.0. Expecting this to be less work we choose the second option.

Step by Step Process:-

  1. Open the 11g migrated Composite in the JDeveloper and goto BPEL source File,  And then change the BPEL namespace just like below:
            Then add the below namespace after the xmlns,
             xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
  1. In the Composite.xml, open the source and add the composite version for the BPEL component as below:
                <component name="bpelprocessname" version="2.0">             
  1. Finally close JDeveloper, delete the SCA-INF directory and restart JDeveloper. The SCA-INF was created again. When opened the bpel process in the editor it was recognized as a BPEL 2.0 process

            

Now, when you rebuild, you can see lot of errors.
  1. Assign Activity (Xpath to XSL):-
The assignment (assign activity) has a major shift in BPEL 2.0. In BPEL 1.1 the assignments were based on XPath but in BPEL 2.0 the assignments are based on XSL notation. Change all the Assign activities like below either changing the Source file (if you are comfortable with XSL & XPATH) or using the BPEL designer.

BPEL 1.1 assign activity looks like:

<assign name="Assign1">
  <copy>
    <from variable=”inputVariable” part=”payload” query=”ns2:/StartRequest/ns2:procesId”/>
    <to variable=”start_InputVariable” part=”payload” query=”/ns6:/Parameters/ns6:procesId”/>
  </copy>
  <copy>
    <from expression=”concat(bpws:getVariableData(‘inputVariable’,’in’,’ns2:/StartRequest/ns2:procesId’,’ tmp’))/>
    <to variable=”tempvalue” />
  </copy>
</assign>

BPEL 2.0 assign activity would be a XSL notation and it looks like:

<assign>
  <copy>
    <from>$inputVariable.payload/ns2:procesId</from>
    <to>$start_InputVariable.payload/ns6:procesId</to>
  </copy>
  <copy>
    <from>concat($inputVariable.in/ns2:procesId,’tmp’)</from>
    <to>$tempvalue</to>
  </copy>
</assign>

Note:-
First open the assign editor for all assignments and closed it again (press ok). If you look at the source before and after, you will notice the contents of the variable and part attribute have been moved to the correct location. The expression and query attribute have not been moved and are still there. You will have to do this yourself. Add them to the variable but remove the first level of the xpath as it is no longer needed.


  1. Assign Activity (XML fragment):-
IF you have assigned a XML fragment to a variable you need to do the following. Enclose the fragment inside a <literal> element.

BPEL 1.1 assign activity looks like:
<assign>
   <copy>
      <from>
         <result xmlns="http://samples.otn.com">
            <name/>
            <symbol/>
            <price>12.3</price>
            <quantity>0</quantity>
            <approved/>
            <message/>
         </result>
      </from>
      <to variable="output" part="payload"/>
   </copy>
</assign>

BPEL 2.0 assign activity would look like:

<assign>
   <copy>
      <from>
       <literal>
         <result xmlns="http://samples.otn.com">
            <name/>
            <symbol/>
            <price>12.3</price>
            <quantity>0</quantity>
            <approved/>
            <message/>
         </result>
      </literal>
      </from>
      <to>$output.payload</to>
   </copy>
</assign>

  1. Assign Activity (insertBefore, insertAfter, remove):-
Often in BPEL we use BPEL extension functions like insertBefore, InsertAfter, remove. In BPEL 2.0 these extension functions are change a bit and also follow the same XML literal pattern.  For Remove operations just add the entire bpelx inside the element “extensionAssignOperation”. But for insertBefore & insertAfter follow the above pattern as well as XML fragment pattern.
BPEL 1.1 assign activity looks like:

<bpel:assign>
    <bpelx:append>
          <bpelx:from variable="billOfMaterialVar"
                query="/b:bom/b:parts/b:part" />
          <bpelx:to variable="consolidatedBillOfMaterialVar"
                query="/b:bom/b:parts" />
    </bpelx:append>
</bpel:assign>
<bpel:assign>
    <bpelx:remove>
       <bpelx:target variable="ncname" part="ncname" query="xpath_str" />
    </bpelx:remove>
</bpel:assign>
<bpel:assign>
    <bpelx:insertBefore>
        <bpelx:from>
             <a:city>Redwood Shore></a:city>
        </bpelx:from>
        <bpelx:to "addrVar" query="/a:usAddress/a:state" />
    </bpelx:insertBefore>
</bpel:assign>
<bpel:assign>
    <bpelx:insertAfter>
        <bpelx:from>
             <a:addressLine>Mailstop 1op6</a:addressLine>
        </bpelx:from>
        <bpelx:to "addrVar" query="/a:usAddress/a:addressLine[1]" />
    </bpelx:insertAfter>
</bpel:assign>

BPEL 2.0 assign activity would look like:

<bpel:assign>
   <bpelx:append>
      <bpelx:from>$billOfMaterialVar/b:parts/b:part</bpelx:from>
      <bpelx:to>$consolidatedBillOfMaterialVar/b:parts</bpelx:from>
   </bpelx:append>
</bpel:assign>
<assign>
   <extensionAssignOperation>
      <bpelx:remove>
         <bpelx:target>$ncname.ncname/xpath_str</bpelx:target>
      </bpelx:remove>
   </extensionAssignOperation>
</assign>
<assign>
   <extensionAssignOperation>
      <bpelx:insertBefore>
         <bpelx:from>
            <bpelx:literal>
               <a:city>Redwood Shore></a:city>
            </bpelx:literal>
         </bpelx:from>
         <bpelx:to>$addrVar/a:state</bpelx:to>
         </bpelx:insertBefore>
   </extensionAssignOperation>
</assign>
<assign>
   <extensionAssignOperation>
      <bpelx:insertAfter>
         <bpelx:from>
            <bpelx:literal>
               <a:addressLine>Mailstop 1op6</a:addressLine>
            </bpelx:literal>
         </bpelx:from>
                     <bpelx:to>$addrVar/a:addressLine[1]</bpelx:to>
      </bpelx:insertAfter>
   </extensionAssignOperation>
</assign>
                    BPEL designer screen for changing these, 
 
  1. JAVA embedding (bpelx:exec & import):-
Sometimes, in our BPEL we import java classes to utilize those functions on the java embedding object.  And also for regular java embedding activity, enclose the Embedded Java activity element (bpelx:exec) by the extensionActicity element and removed the version attribute.
BPEL 1.1 java exec import:-
                <bpelx:exec import="org.w3c.dom.Element"/>

                <bpelx:exec name="evaluateCriteria" language="java" version="1.3">
                                        <![CDATA[// initialize ]]>
                </bpelx:exec>

BPEL 2.0 java exec import is changed to a process level import using the java extension:- This import should be specified at the top of the BPEL, just after the “<process>” element
            <import importType="http://schemas.oracle.com/bpel/extension/java" location="org.w3c.dom.Element"/>

                                <extensionActivity>
                                    <bpelx:exec name="evaluateCriteria" language="java">
                                        <![CDATA[// initialize ]]>
                                    </bpelx:exec>
                                    </extensionActivity>


  1. Switch & Case:-
The switch activity has been replaced by if activity, which is just like our Java language.
·         Just rename the switch to if
·         Make the condition attribute of the first case element a child element of the if element and change it’s xsl variable format (see earlier)
·         All other Case elements become elseif’s. For the condition the same applies as explained before
·         Otherwise becomes else

BPEL 1.1 Switch & Case activity looks like:

<switch name="switch-1">
     <case condition="bpws:getVariableData('loanOffer1','payload', '/autoloan:loanOffer/autoloan:APR') < 10">
          <assign name="selectUnitedLoan">
            <copy>
               <from variable="loanOffer1" part="payload">
               </from>
               <to variable="selectedLoanOffer" part="payload"/>
            </copy>
         </assign>
     </case>
     <case condition="bpws:getVariableData('loanOffer1','payload', '/autoloan:loanOffer/autoloan:APR') > 10">
          <assign name="selectUnitedLoan">
            <copy>
               <from variable="loanOffer1" part="payload">
               </from>
               <to variable="selectedLoanOffer" part="payload"/>
            </copy>
         </assign>
     </case>
     <otherwise>
         <assign name="selectStarLoan">
          <copy>
            <from variable="loanOffer2" part="payload">
            </from>
            <to variable="selectedLoanOffer" part="payload"/>
          </copy>
         </assign>
     </otherwise>
</switch>


BPEL 2.0 Switch & Case activity looks like:

<if name="switch-1">
     <condition>$loanOffer1/autoloan:loanOffer/autoloan:APR < 10</condition>
          <assign name="selectBankLoan">
            <copy>
               <from>$loanOffer1.payload</from>
               <to>$selectedLoanOffer.payload</to>
            </copy>
         </assign>
     <elseif>             
     <condition>$loanOffer2/autoloan:loanOffer/autoloan:APR < 10</condition>
          <assign name="selectUnitedLoan">
            <copy>
               <from>$loanOffer2.payload</from>
               <to>$selectedLoanOffer.payload</to>
            </copy>
         </assign>
     </elseif>
     <else>
         <assign name="selectStarLoan">
            <copy>
               <from>$loanOffer3.payload</from>
               <to>$selectedLoanOffer.payload</to>
            </copy>
         </assign>
     </else>
</if>
  1. The checkpoint element can be replaced by the dehydrate element also enclosed by an extensionActicity element as it is a oracle specific bpel 2.0 extension like the embedded java activity.
  2. The terminate activity just needs to be renamed to exit.
  3. Need to add an additional attribute to the catch element when you are catching faults. This can be a faultMessageType or faultElement. Open the catch fault editor and select the right one.
  4. The until attribute of the BPEL 1.1 Pick/onAlarm element has become a child element in 2.0 and needed to be moved.
  5. Not all annotations <bpelx:annotation> are supported anymore. Comment some of them out for now as they were mainly for documentation purposes only.
  6. Unfortunately the skipCondition attribute is no longer supported.  Its a little disappointment about this although it’s understood why it was removed. This attribute is just not part of the BPEL 2.0 standard. So, we have to add if/then/else constructions to mimic the same.
  7. BPEL 2.0 refactoring:-
Since the BPEL process is upgraded to 2.0 from 1.1, we have some refactoring options also which would be worth doing it.
·         In BPEL 2.0 there is the notation of variable initialization. Where in BPEL 1.1 we needed an additional assign activity to initialize a variable, in 2.0 it can be done as part of the variable definition. So we can make the BPEL process cleaner by moving the initialization to the definition part.
·         The assign activity has some additional functionality: keepSrcElementName (in BPEL 2.0 projects only): Select this option to toggle the keepSrcElementName attribute on the copy rule on and off. This option enables to replace the element name of the destination (as selected by the to-spec) with the element name of the source.
·         Change Rule Type (in BPEL 2.0 projects only): Select this option to change the type of the selected rule to one of the BPEL extension rules: bpelx:copyList, bpelx:insertAfter, bpelx:insertBefore, or bpelx:append.

For six moderate to complex BPEL processes this cost me about a week work. For our project it was not cost effective to automate this. We could have created  an xsl transformation to do parts of the migration. I wonder if you could fully automate this especially the refactoring part.

No comments: