L05 GraphicalMapping

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

IBM Software

Lab 5 Graphical Mapping

5.1 Overview
This lab exercise introduces the graphical mapping node that was new to version 8 of the product.

By way of illustration, here is an example of one of the maps that will be built in the lab. To summarize
what this shows: there are source and target message assemblies on the left and right hand sides
respectively; fields in the output are then assigned values or graphically mapped from the input fields
with the connections formed in the central area.

In the last lab, an initial web service flow was created that simply returned to the caller the message it
was sent. In this lab, the flow is expanded to call a backend service and return a response based on the
result of this service invocation. The backend service uses the MQ transport and is pre-built. Before the
message flow can send a request to our backend service, it must be transformed from the XML of the
request to a COBOL format. The backend Account_Open service will return a response in an MQ
message. The response will have to be transformed from COBOL back to a XML reply message format.
The transformations will be done using the graphical Mapping node.

The completed flow will look like the following.

Page 94 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

5.2 Extending the Web Service


In this lab we will be adding all of the nodes shown on the previous page, in between the
JKE_WSDL_ServerService node and the SOAP Reply node to perform the following high level
tasks:
• Transform the XML to COBOL – Build Request (mapping)
• Send and receive messages to the backend service – Invoke MQ, Set Correl Id, Get
Reply
• Transform the returned COBOL to XML – Remove MQMD, Create Reply (mapping)

__1. Start by selecting the AcctOpen_Application project. Press the right mouse button on the
AcctOpen Application and select Manage Library references from the menu

__2. Select the MQ_Service_Library project to add it to the list of libraries referenced by the project.
The other library, AcctOpen_Library, was created and the reference was established when the
application was initially created in the previous lab.

__3. Press the OK button.

Lab 5 – Graphical Mapping Page 95


IBM Software

__4. Open the Transformation drawer.

__5. Drag a Mapping node onto the connection between the JKE_WSDL_ServerService sub-flow
and the SOAP Reply node. Drop it on the connection near the sub-flow. You will know when it is
in the correct place to be dropped when a bubble with the words Insert a node into the
connection apears.

Once the mapping node is dropped onto the connection, the original connection is broken into
two sections. The input node is connected to the sub-flow and the output terminal is connected to
the SOAP Reply node. We will use this technique for the remaineder of this lab. If at anytime the
node is not dropped onto the existing connection, you will need to delete the old connection and
re-wire the two new connections.

__6. Rename the mapping node to Build Request. This node will transform the SOAP response
received from the Web service client to a COBOL structure that matches what the MQ based
service expects.

Page 96 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__7. Drag another Mapping node onto the connection to the left of the SOAP Reply node. This node
will transform the response received from the MQ service to the response expected by the web
service.

__8. Rename the Mapping node to Create Reply. The SOAP Reply node may need to be moved to
the right to provide space for the new nodes.

An MQ Output node will be used to invoke the MQ-based service.

__9. Select the WebSphere MQ drawer.

__10. Drag an MQOutput node to the connection just after the first mapping node, Build Request.
This node will send a request message to the MQ-based service. Rename the node to Invoke
MQ.

Lab 5 – Graphical Mapping Page 97


IBM Software

__11. In the Properties pane for the Invoke MQ node select the Basic tab.

__12. Enter JKEACCTOPEN.IN as the Queue name. This is the queue that the queue based service
will be waiting for messages on.

Next the node must be configured to put the message immediately and not as part of the flow’s
transaction.

__13. Select the Advanced tab.

__14. Use the drop down menu to set the Transaction mode to No.

__15. Use the drop down menu to set the Message context to Default.

Page 98 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

Finally the node needs to be configured to send a request message along with the reply-to queue
name.

__16. Select the Request tab.

__17. Select the Request check box.

__18. Enter LAB.REPLY as the Reply-to queue. The reply-to queue manager does not need to be
filled out as we will not be sending messages between different queue managers.

Replies sent to this reply-to queue will be got by an MQ Get node.

__19. Drag an MQGet node to the right of the Invoke MQ node and drop it onto the connection. Allow
room for another node in between the new node and the Invoke MQ node.

__20. Change the name to Get Reply.

Lab 5 – Graphical Mapping Page 99


IBM Software

__21. In the Properties pane select the Basic tab.

__22. Enter LAB.REPLY as the Queue name.

__23. Select the Input Message Parsing tab.

__24. Use the drop down menu to select the DFDL parser as the Message domain. Then select the
Browse…button.

__25. Expand MQ_Service_Library and DFDL Schemas then select JKEACCOUNTREQUEST{} as


the message.

__26. Close the window by pressing OK.

Page 100 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

The result should look as follows with the JKEACCOUNTREQUEST DFDL message provided in
the MQ Service Library being used by the node.

The final configuration we need to make to this node is to set it to get messages outside of the
transaction of the flow.

__27. Select the Advanced tab.

__28. Set the Transaction mode to No.

The reply message is received from an MQ service and therefore will have an MQMD header.
Since the original message originated as a SOAP Web service over HTTP the MQMD will be
removed using an MQ Header node.

__29. For the next step you may need to move the nodes around to make room between the Get
Reply and SOAP reply nodes

__30. Drag an MQ Header node to the message flow placing it after the Get Reply mapping node.

Lab 5 – Graphical Mapping Page 101


IBM Software

__31. Rename the node to Remove MQMD.

__32. In the Properties pane select the MQMD tab.

__33. Click the radio button for Delete header.

There is still one subtle error in the message flow. The MQ Get node just reads the next
message from the reply queue. It does not check if the reply message actually matches the
request that was sent. The MQ Get node should look for the specific message that correlates
with the specific request that was sent. WebSphere MQ provides a correlation id field that is set
by the remote application to the message identifier of the message that was sent. The message
id of a message that is sent by an MQ Output node is captured and stored in an area of storage
called the local environment.

The next steps will use an MQ Header node to get the message identifier from the local
environment and store it in the correlation id field of the MQMD. The properties of the Get Reply
node will also be changed to only get the specific reply message.

__34. Select another MQ Header node from the palette and drag it onto the connection between the
Invoke MQ and Get Reply nodes.

__35. Rename the node to Set Correl Id.

Page 102 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__36. In the Properties for the Set Correl Id node select the MQMD tab.

__37. Select the Modify header radio button.

__38. Scroll down so that the Correlation Identifier field is visible.

__39. Press the Edit button next to the Correlation Identifier field.

Lab 5 – Graphical Mapping Page 103


IBM Software

__40. Expand the $LocalEnvironment à WrittenDestination à MQ à DestinationData folders.

__41. Select the msgId field and drag it to the XPath Expression edit box.

It is possible for an MQ Output node to send multiple messages in a single invocation and there
might be more than one occurrence of the DestinationData folder, one for each message that
was sent. In this case there is only a single message so that the first (and only) occurrence will
be selected.

__42. Confirm that the occurrence value is set to 1.

__43. Press the OK button to select the first occurrence of the DestinationData folder.

Page 104 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__44. Check the XPath expression has been generated correctly as


$LocalEnvironment/WrittenDestination/MQ/DestinationData[1]/msgId.

__45. Press the Finish button to complete the XPath expression for the Correlation Identifier field.

__46. Select the Get Reply node.

Lab 5 – Graphical Mapping Page 105


IBM Software

__47. In the Properties pane select the Request tab.

__48. Select the Get by correlation ID check box.

At this stage the construction of the flow is complete.

__49. Verify that the connections are correct.

__50. Save the message flow <Ctrl-S>.

Page 106 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

5.3 Build the Graphical Mapping


In the next series of steps, maps will be created for the two mapping nodes, Build Request and
Create Reply. The Mapping wizard is started by double-clicking on a Mapping node.

__1. Double-click the Build Request node to start the wizard.

__2. The first panel of the wizard gives you the option to change the name of the map and select the
container in which the map will be stored. There is no need to change any of these for the lab so
click Next.

Next a panel is displayed where you identify the source and targets for the mapping operation. It
can be expanded until all items are shown or scrolling can be used to see the message
definitions.

Lab 5 – Graphical Mapping Page 107


IBM Software

Select the map input.

__3. In the left hand half expand the AcctOpen_Library and DFDL and XML Schemas folders.

__4. Check the box next to JKE_In_Request. This will be the input message for the mapping

Select the map output.

__5. In the right hand half expand MQ_Service_Library and DFDL and XML Schemas folders.

__6. Check the box next to JKEACCOUNTREQUEST. This will be the output message for the
mapping

__7. Click Next.

On this pane of the wizard we specify the domain of the output message.

__8. From the drop down select DFDL for the Output domain.

__9. Click Finish.

Page 108 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

The initial map is then presented showing the input and output messages.

The Mapping Panel is divided into three areas. On the left hand side is the input or source message,
here shown pre-populated with the input Properties and the JKE_In_Request message. On the right
hand side is the target or output message, here shown pre-populated with the output Properties and the
JKEACCOUNTREQUEST output message.

Note that the Properties folder has already been mapped. This mapping moves all of the properties from
source to target with one override of an assignment to the Message Type.

Lab 5 – Graphical Mapping Page 109


IBM Software

__10. Select the Assign map and look at its properties. In the General tab the Value of the
assignment for the message type is set to {}: JKEACCOUNTREQUEST.

So these output properties will indicate the change of the message type for subsequent nodes.

__11. Collapse the Properties folder, to focus on the task of mapping the input and output messages.

__12. From the buttons above the main map, select the Auto map input to output button.

Page 110 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

This mapping operation is between messages of different formats – XML for the source, COBOL
for the target. The field names are different, the order of fields is different in some cases, and in
two cases data that is a string in the source becomes Packed Decimal (for one field) or Binary
(for another field).

__13. In the Auto Map wizard, uncheck the box for Alphanumeric characters.

__14. Select the check the box for Create transformations when the names of inputs and outputs
are similar than.

__15. Set the % match to 50 using the slider bar or by overtyping the value.

__16. Click Next.

A comparison of the names will be performed and the results shown on the next screen.

A preview of the results of the Map by Name operation using the parameters supplied on the
previous panel is displayed. If the results are not satisfactory then the Back button can be used
to return to the previous panel. This panel allows for incorrect or duplicate mappings to be
removed.

Lab 5 – Graphical Mapping Page 111


IBM Software

In this case the CUSTOMER_ACCOUNT_NUMBER target has two sources. This is not right. It
will now be corrected.

__17. Select the line with two sources (CUSTOMER_ACCOUNT_NUMBER).

__18. Click on the Edit button.

__19. Uncheck the box for customerCountry as this is not the proper source for this target. Leave
the customerNumber field checked as this is the source for this field.

__20. Click OK to remove the incorrect mapping.

Page 112 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

You should see that the CUSTOMER_ACCOUNT_NUMBER target now has a single source with and
input count of 1.

__21. Click the Finish button to perform the mapping.

Lab 5 – Graphical Mapping Page 113


IBM Software

Take a few minutes and look at the results. Fields from the source and target are now connected by
Move mappings that have been generated by the auto map wizard. If there is a mapping that is
incorrect, you can click on the Move that joins them, and delete it.

If you look closely you will see that there are four target fields (ACTION_REQUEST, CITY, COUNTRY
and DECISION) that the Map by name algorithm was not able to establish a match for. At a 50%
matching criteria, the shorter names missed a match because of the “customer” prefix in front of those
fields in the source names. To illustrate mapping by hand these elements will be mapped manually. A
simple drag and drop can be used to map from source to target.

When dealing with fixed format messages, such as COBOL, every field must be mapped unless that field
has been defined with a default value. It is also worth noting that the COBOL items do have a max
length associated with each field. When mapping from variable length fields, such as XML, if a source
field is too long it will be truncated in the target. With the sample messages provided with the lab, this is
not the case.

You may also notice that two of the mappings have warnings, for both the customerCreditLimit and
CustomerCreditScore input fields. This is where strings are being mapped to something other than a
string -- the field types between the move do not match. We will correct these once the missing maps
have been provided.

Page 114 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__22. To map the first field, drag and drop the source customerCity field, on the left, to the target
CITY field, on the right. (Collapse the target Properties folder again if necessary.)

This should create a new map represented by the Move joining the two fields.

__23. Repeat this for the source customerCountry field dragging it onto the target COUNTRY field.

That completes the two missing moves for this map.

Lab 5 – Graphical Mapping Page 115


IBM Software

Next two assignments are made for the DECISION and ACTION_REQUEST target fields.

__24. Right click on the DECISION field in the target half.

__25. Select Create Assign from the menu.

__26. With the new Assign map selected go to the Properties tab.

__27. Enter a single character Y as the value for this assignment.

Page 116 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__28. Right click on the ACTION_REQUEST field in the target half.

__29. Select Create Assign from the menu.

With the new Assign map selected go to the Properties tab.

__30. Enter a single character (letter) O as the value for this assignment.

Lab 5 – Graphical Mapping Page 117


IBM Software

Now it is time to deal with the two warnings within the generated map.

__31. Locate the Move map for the customerCreditLimit. Hover over the warning symbol (a small
yellow triangle containing an exclamation mark) to reveal the details of the warning. The warning
text is: The string simple type input does not match the <PICS9-Comp3__int> simple type
output. Use a Convert transform to ensure proper conversion.

__32. Move the cursor to hover over the light bulb (just next to the warning symbol).

__33. Select the quick fix that is being offered: Use convert to ensure the proper conversion.

Repeate this process to resolve the remaining warning in the map

__34. Locate the Move map for the customerCreditScore.

__35. Once again move the cursor to hover over the light bulb (just next to the warning symbol).

__36. Select the quick fix that is being offered: Use convert to ensure the proper conversion.

Page 118 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

Here is the end result with all fields properly mapped. Every field on the target side should have an
associated mapping to it. Note that CUSTOMER_DETAILS is not a field but a structure that contains
multiple fields.

Lab 5 – Graphical Mapping Page 119


IBM Software

There is one more consideration for the map to be complete. The input message arrives over an HTTP
transport. The output message will be sent over WebSphere MQ. The input message will contain an
HTTP input header, which should be removed before sending the message to MQ. The removal of the
HTTP header could also be accomplished using an HTTPHeader node. However in this case the
mapping node will be used to remove the header. This is accomplished by adding the header on the
target side of the map but not mapping to it.

The MQMD header will then be added by the MQ Output node as this puts a message to the queue.

__37. Select the output Message Assembly.

__38. In the General Properties click on Edit for the Headers and folders.

Page 120 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__39. Expand the HTTP Headers folder (Do not select all the headers at this level).

__40. Select the check box next to the HTTPInputHeader header.

__41. Press the OK button to add the header.

Note the HTTPInputHeader is now referenced in both the graphical map (shown here with the
target properties minimized) and the Headers and folders property.

The map is now complete.

__42. When you are finished examining the results, save the map (Ctrl+S).

Lab 5 – Graphical Mapping Page 121


IBM Software

__43. Close the mapping editor.

The second map will be built next.

__44. Double-click on the Create Reply node.

__45. As before there is no need to change what the map is called or where it will be stored so click
Next.

Page 122 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

Select the map input.

__46. In the left hand half expand the MQ_Service_Library and DFDL and XML Schemas folders.

__47. Check the box next to JKEACCOUNTREQUEST. This will be the input message for the
mapping

Select the map output.

__48. In the right hand half expand AcctOpen_Library and DFDL and XML Schemas folders.

__49. Check the box next to JKE_Out_Response. This will be the output message for the mapping

__50. Click Next.

The output message will be the reply to the web service in SOAP XML.

__51. This time leave XMLNSC as the Output domain.

__52. Click Finish.

Lab 5 – Graphical Mapping Page 123


IBM Software

__53. To once again auto-generate some of the map from the buttons above the main map select the
Auto map input to output button.

__54. Uncheck the box for Alphanumeric characters.

__55. Select the check the box for Create transformations when the names of inputs and outputs
are similar than

__56. Set the % match to 50 using the slider bar or by overtyping the value.

__57. Click Next.

Page 124 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__58. Uncheck the box for mapping to the message.

Note that the requestDecision target has two sources.

__59. Select the line with two sources (requestDecision).

__60. Click on the Edit button.

Lab 5 – Graphical Mapping Page 125


IBM Software

__61. Uncheck the box for ACTION_REQUEST as this is not the proper source for this target. Leave
the DECISION field checked as this is the source for this field.

__62. Click OK.

You should see that requestDecision now has a single correct source (DECISION).

__63. Click on the Finish button to perform the map by name operation.

In the map that has been generated, only one target field remains unmapped this is the message
field.

__64. Drag COMMENTS in the source message assembly to message in the target.

Page 126 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__65. Verify that all items have been mapped.

__66. Save the map.

__67. Close the mapping editor.

__68. Save the message flow.

Lab 5 – Graphical Mapping Page 127


IBM Software

5.4 Test the Message Flow


It is now time to test the message flow. The flow test that was saved in the previous lab will be
reused.

This message flow has a dependency on an MQ service. In this case, the service will be
simulated by another message flow, which has been provided. A flow created prior to version 8
of the product will be used for this service. This flow is not encapsulated within an application but
contained in a message flow project.

__1. Expand the Independent Resources folder, then the MQ_Service message flow project, and
the Flows folder.

__2. Right click on the JKE_AccountOpen message flow.

__3. From the menu select Deploy.

Page 128 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__4. Select the default execution group

__5. Click Finish.

__6. Once the flow has deployed, you should observe the JKE_AccountOpen message flow, the
MQ_Service_MessageSet message set and the JKE_AccountOpen ESQL deployed and
running within the Brokers pane.

With the backend service in place we can now run test messages through the main flow.

__7. In the project navigator pane expand Flow Tests for the AcctOpen_Application.

__8. Double click the AcctOpen_Flow.mbtest file to open the previously saved test file..

Lab 5 – Graphical Mapping Page 129


IBM Software

The test client should open. The test data from the previous test should appear in the test client.

__9. Select the Configuration tab.

__10. Select the MQ Settings configuration.

__11. Uncheck the Stop when the first MQ message is received check box.

__12. Select the Browse message from MQ output queue radio button.

Without these changes the test client will attempt to get messages from the queue being used by
the backend service and interrupt the flow that is being tested.

Page 130 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

__13. Return to the Events tab.

__14. In the left hand pane, right click on the Invoke Message Flow entry.

__15. Select Re-run from the menu.

This will repeat the previous test with the same data that was run by the client.

Lab 5 – Graphical Mapping Page 131


IBM Software

__16. Wait for the HTTP Reply to be received.

__17. Press the small square icon to stop the test. The flow test is waiting for a message to arrive on
the queue, but the message has been processed by the other flow. The message flow will
eventually time out.

__18. Select the Received HTTP Reply message for “SOAP Input” in the left hand pane. The
results will be displayed in the right hand pane.

Observe that data has come back from the backend service in the customerNumber and
message fields. The flow has mapped the request that was sent from the SOAP format into the
COBOL structure and on the way back the COBOL has been mapped to the SOAP response
format.

__19. Ensure that the test has stopped.

__20. Close the test client.

__21. Press the Yes button to save the test client.

Page 132 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA
IBM Software

5.5 Clean up
__1. Close the AcctOpen_Flow message flow.

__2. Return to the MQ Explorer window.

__3. Expand the MB8BROKER message broker entry.

__4. Select the default execution group.

__5. Press the right mouse button.

__6. Select Delete All Flows and Resources from the menu.

__7. Press the OK button to acknowledge the warning and start the deletion.

Lab 5 – Graphical Mapping Page 133


IBM Software

The default execution group should now be empty.

This is the end of Lab 5.

Page 134 Discovering the value of WebSphere Message Broker V8.0 for your ESB and SOA

You might also like