Message Parsing Application is exactly the opposite of Message Serialization Application. Message Parsing Application transforms XML-data or SWIFT-data loaded from an external file into the structured data that can be used in the Stardust model. The values defined in the XML/SWIFT-file are assigned to the corresponding fields of the structured data.
Note: All files referenced in this article, including MessageParsingExample.xpdl, Customer.xml and the Java POJO can be extracted from here.
Following model is used to implement an example of message transformation application (MessageParsingExample.xpdl):
Using Plain Java Application Load XML Data App, determine the input message to be parsed as a string read from an XML-File (here: Customer.xml)
Using Message Parsing App, parse the XML-message (here: InputMessage) as a structured data Customer
Display the values of the structured data Customer, loaded from Customer.xml
Configuration of Message Parsing Application
Steps in general:
- Specify Source Message Format and Target Message Type
- Create IN Data Mapping from the input message
- Create OUT Data Mapping to the structured data the input message should be parsed into
- Create a Message Parsing Application, selecting Application in the diagram toolbar palette and choose Message Parsing Application
- Open the properties of the Message Parsing Application. Select the Source Message Format (here: XML) and the Target Message Type. For Target Message Type, select the Structured Data that corresponds to the XML-Data (i.e. input message) you'd like to parse (here: Customer).
- Create a primitive data of type String that contains the input message that should be parsed into the structured data. Here the corresponding primitive data Input Message is set using the plain java application Load XML Data App that transfers the content of an external XML-file (here: C:\tmp\Customer.xml) into a String.
In the model used in this example, the input message is read from the external XML-File Customer.xml which location is not selected by the user but is hard-coded in the Load XML Data App to simplify the model. Thus, if you'd like to test the model provided within this example make sure the file C:\tmp\Customer.xml exists.
- Within the application activity that corresponds to the Message Parsing Application (here: Parse Message), create an IN Data Mapping from the primitive data containing input message (here:Input Message).
- Within the application activity that corresponds to the Message Parsing Application (here: Parse Message), create an OUT Data Mapping into the structured data into which the message should be parsed (here: Customer).
- Make sure the access points for the correspondent mappings are set correctly (IN Data Mapping:InputMessageString: java.lang.String; OUT Data Mapping: OutputMessage(Customer)).