BPEL Designer and Service Engine User's Guide

Using Type Cast and Pseudo-Components

Type Cast and Pseudo-components are provided to support type inheritance, help build message structure, and prevent validation errors. Type Casting addresses a problem in which a base complex type does not contain the same elements as the derived type.

For example, a variable may have a base type, containing two attributes and two elements, and a derived type inherited from the base type, containing an additional attribute and element.

Image shows a base type and a derived complex
 type in the Design view of the XML Schema

When the message is declared in a WSDL for use in BPEL, the base type is used to declare the message. So, in this example, from the Mapper view of the XML structures we see the variable's base type that does not contain the additional element and attribute.

Image shows the Mapper view displaying the variables
base type

Since the Mapper is designed to allow you to graphically link elements and attributes, these structures need to be available in the mapper view. To allow mapping of derived type attributes and elements, which are implied by the base type, the Mapper enables you to cast an object to another type - in this example, to the derived type.

    To cast an object to another type:

  1. From the Mapper view of the project's bpel file, right-click the variable that has the base type and click Cast To in the context menu. The Subtype Chooser appears displaying a tree with the original type as the root and subtypes under the root. If there are no subtypes, only the original type will appear in the box.

    Image shows the Bpel Mapper view containing the
new derived type variable as described in context
  2. To cast the original variable to the derived type, select derivedType in the Subtype Chooser and click OK. The derivedType variable appears in the Mapper.

  3. Expand the derivedType variable in the Mapper and note that the additional attribute and element are now available to use for mapping.

Type Cast

The Type Cast option allows you to explicitly cast an object to another type. This only works for objects that have a schema type.

In the BPEL Mapper the following object can be casted:

Pseudo-Component

The Pseudo-component feature is similar to Type Cast. The XML Schema introduces xsd:any. It declares that an element can be located in the XML document and have any name and type. The BPEL mapper allows you to add to the tree elements, which correspond to xsd:any. Such elements don't appear in the schema, but they look similar to other elements. That is why they are called pseudo-elements. The user can map from and to a pseudo-element the same way as for an ordinary element. This also applies to the xsd:anyAttribute. The user can create pseudo-attributes to use for mapping and design purposes.

In the Mapper's Input and Output trees, xsd:any appears as an element node with the name "Any Element" and xsd:anyAttribute as an attribute with the name "Any Attribute". Both have the context menu item "Cast To...", which calls the special dialog box used to specify a name, namespace and type for the new pseudo-component. For xsd:any any global type can be chosen. For xsd:anyAttribute only the global simple types are suggested. In both cases the settings allow you to choose global types from several different sources. The completed pseudo-components appear in the tree with the name pattern (castToElementName)Any Element or (castToAttributeName)Any Attribute.

Image shows the pseudo-components, Any Element
and Any Attribute in the Mapper's Output tree.

Type Cast and Validation

Validation is passive in regard to type casts and pseudo-components, meaning that validation does not object to an unknown component if it is a qualified type cast or it is declared as a pseudo-component.

Type Cast and Pseudo Component Limitations

The type cast is used to avoid runtime errors, but there are several reasonable limitations: