WebSphere

Set Message Type mediation primitive

Use the Set Message Type mediation primitive to overlay message fields with more detailed structures. You can then manipulate message content more easily.

Introduction

Essentially, the Set Message Type mediation primitive allows you to treat weakly-typed message fields as though they are strongly-typed. A field is weakly-typed if it can contain more than one type of data. A field is strongly-typed if its type and internal structure are known. The Set Message Type mediation primitive lets you do the equivalent of casting a generic data type to a more specific data type.

Typically, a weakly-typed field is declared as having an XML schema type of anyType or anySimpleType, or is an XML wildcard element (any). Less commonly used weak-typing constructs are abstract types and substitution groups.

The Set Message Type mediation primitive lets you overlay message fields with more detailed structures, and then use the more detailed structures in other mediation primitives. For example, if a message field is defined to contain any type of content but you know it will contain customer details, you might overlay the generic structure with a customer details structure.

After you define how weakly-typed fields are to be interpreted, the WebSphere® Integration Developer tools show the more detailed structures. The more detailed structures make it easier for you to manipulate the message content. For example, you could create mappings that operate on the contents of the weakly-typed fields.

The Set Message Type mediation primitive has one input terminal (in), one output terminal (out), and a fail terminal (fail). The in terminal is wired to accept a message and the other terminals are wired to propagate a message. At run time, if no exception occurs during the processing of the input message, the out terminal propagates the unmodified message. However, if an exception occurs during the processing of the input message, the fail terminal propagates the original message, and stores the exception information in the failInfo element of the service message object (SMO). The fail terminal is used if you enable validation, and the input message fields do not conform to the strong data types you specify.

Details

After you wire together all parts of your mediation flow, and configure your mediation primitives, every terminal has a terminal type with an associated message type. When you specify strongly-typed data, using the Set Message Type mediation primitive, this information is associated with the out terminal.

Using the Set Message Type mediation primitive you define how fields in the input message are to be interpreted and this information is accessible to mediation primitives that come later in the mediation flow. The information specified by the Set Message Type persists through the rest of the mediation flow, unless another mediation primitive changes the message type. For example, an XSLT mediation primitive might change the message type, or another Set Message Type might reset the strong-typing.

Usage

An ESB is often used to make routing decisions based on message content, and to transform messages to a format understood by the service provider. In order to make routing decisions, or specify transformations, it is useful to have a complete representation of the message. If the XSLT mapping editor, or XPath wizard, shows your message contains weakly-typed fields, you can overlay these with a detailed representation using the Set Message Type mediation primitive. Without the Set Message Type capabilities, you might have to write Java™ code for a Custom Mediation primitive, or create a hand-written XSL stylesheet for an XSLT mediation primitive.

XML schema definitions sometimes use weakly-typed fields to represent message content that can vary. For example, an XML schema might define a generic message type that can hold different payload types. However, if you know what the exact message format is, you can use the Set Message Type mediation primitive to make the format known to the tools, and the other mediation primitives in the flow.

You can use the Set Message Type mediation primitive to treat a weakly-typed message field as though it is a strongly-typed field. You can also use the Set Message Type mediation primitive to treat a strongly-typed field as though it is contains data of a different strong type. However, the new strong type must be derived from the strong type declared in the input message.

At run time, the Set Message Type mediation primitive lets you check that the message content matches the specific data types you expect.

Properties

Message field refinements
Use the Message field refinements property to specify which fields in the message are refined by more specific typing information. By default, this property is empty. Generally, refine fields that are defined by the following XML schema weak types: xsd:any, xsd:anyType, xsd:anySimpleType, and fields that are defined to be replaceable using substitution groups. You specify the XPath of the message field you want to refine, and the data type to use. WebSphere Integration Developer provides a graphical interface to help you specify the XPath and data type. You can specify refinements for more than one message field, but duplicate entries for the same message field are not allowed.
Weakly typed field
Specify the XPath of the weakly-typed field you want to refine.
Actual field type
Specify the data type you want to use for the refinement.
Reset message type
If true, causes the current mediation primitive to forget Message field refinements information from previous Set Message Type mediation primitives.
Validate
If true, causes causes the Set Message Type mediation primitive to perform runtime validation. The validation includes all message fields and not just those that you have overlaid. If there is a mismatch, an exception occurs and the fail terminal propagates the original message, and stores the exception information in the failInfo element of the SMO. The exception information stored is the text of message CWSXM3802. For example, CWSXM3802E: The type at /body/operation1/input1/float is 'string', while the asserted type states it should be 'float'.
Table 1. Set Message Type mediation primitive properties
Property Valid Values Default
Message field refinements Weakly typed field XPath  
Actual field type    
Reset message type Boolean: true or false false
Validate Boolean: true or false false

Considerations

Consider the following when using the Set Message Type mediation primitive:


reference Reference topic

Terms of use | Feedback


Timestamp icon Last updated: 20 June 2010 00:40:03 BST (DRAFT)


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.wbit.help.medprim620.doc/ref/rwesb_SetMessageTypemediationprimitive.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
This information center is powered by Eclipse technology (http://www.eclipse.org).
iDoc on