AVIO Consulting

BPEL 11g Transform Activity vs Assign Activity

Mar 5, 2013 | General

For those who are new to BPEL 11g, the difference between the transform activity and the assign activity can be potentially confusing. Both can copy data from one variable to another. Both can do xslt transformations. Both can format data. In this situation where, on the surface, both activities seem to perform the same function, what are the rule of thumb guidelines for when to use the assign activity and when to use the transform activity?

Advantages of the Transform Activity

  1. Mapping from multiple input source variables – One of the chief improvements to the transform activity between BPEL 10g and 11g was the ability to map multiple input source variables within one transform. This eliminates having to do the logical gymnastics of stringing together a family of assign transforms when mapping complex transformations. For instance, if I have one source variable that has an array of elements which are keyed by social security number and then I have another variable with a smaller list of social security numbers that need some special processing, within one transform activity, the user can loop thru the first list of SSNs and only retrieve those records with SSNs from the second list, which will then be inserted into the target variable. This would be difficult at best with assign activities and certainly couldn’t be done within one assign activity
  2. Use of variables created in run time in the xsl to complex mappings – In complex mappings, especially in looping scenarios, you may run into situations where you need to create a variable in run time to hold a piece of data that will be used later complete a mapping. For instance, in the scenario described above, it would be very easy to create a for loop around the second set of SSNs. Then within that for loop, create a variable that retrieves the specific record from the first set of SSNs by keying off of the SSN that is currently being evaluated within the for loop. This variable can then be used to retrieve various pieces of data from the first list without having to repeat the complex mapping that arrived at that particular instance for each field.
  3. Mapping data in loops – While the assign activity does support looping within its xslt transformation, it cannot map blocks of data as easily as the transform activity can. For instance, assume that you must compile an array of objects for submission to a credit reporting web service. Each object could have an applicant’s SSN and current address but perhaps that web service also needs information from the submitter as well as a record number calculation. While it may be possible to do these things using the assign activity, these would have to be done in a series of assign activities and couldn’t be done within one activity.
  4. Mapping a large number of variables – The transform activity has big advantages over the assign when mapping a large number of variables. For instance, suppose that you have to map a user’s existing loan information into a new loan application. You can imagine the amount of data that would need to be evaluated, including loan amounts, payment history, interest rates, etc. In addition, the new loan application would also need to include information from a credit report, which could include not only the credit rating, but also number of accounts as well as corresponding information for each account, delinquencies, etc. If just these two transforms were done as assign activities, you would have to create dozens of individual mappings – one for each field.
  5. Visualization of complex mappings – The transform activity is designed to provide an easy to use, intuitive interface to link input data to output data. The user can literally drag and drop inputs to outputs in a way that isn’t possible in the assign activity. In the transform activity, the developer can quickly see those same 50 – 100 mappings on the loan application that was discussed in the previous point in one view that easily shows inputs and their corresponding outputs as well as any potential data discrepancies. This simply isn’t possible with the assign activity.
  6. Ability to test your mapping — The transform activity allows the user to test their transformation right in the xslt editor. This is not possible in the assign activity. This is enormously helpful when working with complex mappings. When testing, the user can edit all of the input data to suit their needs as well as view the output. This is something that should always be done before deploying your process in order to catch simple errors earlier in the development cycle.

Example of how the transform activity allows developer to test an xslt mapping

Advantages of the Assign Activity

  1. Performing a mapping where the source and target schemas are identical – If you need to simply copy one schema to another where both the source and the target schemas are identical then the easiest way to do this is by using the assign activity. While the transform activity can do this thru the auto mapping wizard it is still technically and visually easier to do this using an assign activity. For instance, if you need to simply copy a user’s address from the loan application form from the web page to a web service request, the easiest way could be to simply copy that address block from the web page’s loan application schema to the web service’s request schema assuming both are identical.Example of using the Assign Activity to map data from identical source and target schemasExample of using the Transform Activity to map data from identical source and target schemas
  2. When mapping a small number of non-looping variables – If you only need to copy one or two variables, it is sometimes simpler to just use an assign activity versus using the transform activity where the developer will need to ensure that all of the other data in the object is copied field by field or else it will be lost. For instance, assume that you have a while loop within your BPEL process that will iterate thru a list of customers in order to make one web service call per customer in order to perform an audit of the loan application. In this case, it’s easiest to simply use an assign activity to increment the variable that the while loop is evaluating.

Example of mapping a single variable in an assign activityExample of mapping a single variable in a transform activity

In conclusion, it’s usually best to use the transform activity in BPEL 11g because of the flexibility, visibility, testability and ease of use compared to the assign activity. However, the assign activity has advantages over the transform activity when you need to map a whole source schema to an identical target schema or when you need to map a small number of non-looping variables.