MEC Part 4 – XML Detection

In my previous post we learnt how to set up a partner agreement and we used channel detection to identify the input file and trigger a MEC process.

Channel detection is really useful in integrations where the 3rd party application does not have the capability of generating customized XML files or only has the capability of generating flat files. However, this detection method becomes little bit inconvenient, if there is a huge number of different integration points. Then for each integration point, separate input channel should be configured (separate input folders as well) and managing a huge number of input channels would become a nightmare.

But, what if we can read the data inside the input XML file and detect the file and trigger different MEC agreements based on its contents. It would be really cool, isn’t it? Partner Administrator provides this capability through XML detection.

Consider below XML that is coming from the Customer Portal (example from previous post).

<CustomerPortalRequest>
  
    <RequestHeader>
        <Environment>TEST</Environment>
        <Entity>CustomerOrder</Entity>
        <Operation>Create</Operation>
    </RequestHeader>
    
    <RequestBody>
        <CustomerOrder>
        </CustomerOrder>
    </RequestBody>

</CustomerPortalRequest>

Let’s assume that customers can update their address details from the customer portal. These address details are updated in M3 through MEC. In this case, MEC should be able to differentiate a Customer Order Creation request from a Delivery Address Update Request. We can easily do this using XML detection based on the values in Environment, Entity and Operation nodes. We can pass Address in Entity node and Update in Operation node.

<CustomerPortalRequest>
  
    <RequestHeader>
        <Environment>TEST</Environment>
        <Entity>Address</Entity>
        <Operation>Update</Operation>
    </RequestHeader>
    
    <RequestBody>
        <CustomerAddress>
        </CustomerAddress>
    </RequestBody>

</CustomerPortalRequest>

For this first we need to create a new XML Target Group.

Creating New XML Target Group
  1. Go to Partner Administrator Tool and go to Manage → Detections

Detections

2. In Detections window go to Targets → XML tab. Here we need to define absolute Xpaths of the nodes (XML Targets) that we are going to use for XML detection. Click New.

Detections Window

3. First we create a XML target for Environment node. In Create New Target window, enter the name as cp:env (you can enter any name here). In the Path textbox enter the absolute Xpath to the Environment node (/CustomerPortalRequest/RequestHeader/Environment). Click OK.

Environment

4. In the same way, create XML targets for Entity and Operation nodes as well.

  • cp:entity – /CustomerPortalRequest/RequestHeader/Environment
  • cp:operation – /CustomerPortalRequest/RequestHeader/Operation

5. Now we need to define a Target Group by adding the above XML targets together. Go to Target Groups → XML tab and click Create Group.

Create Group

6. In Create New Target Group window, give the group a name and a description. Then click Create.

Create New Target Group

7. Once the target group is created, we need to add targets to it. For that, add required targets from unused targets.

Targets

8. In this case add all three targets we created in step 3 and 4. Then click Save.

Selected Targets

9. Now we need to add this newly created Target Group to the XML Detection List. Go to Detection Order Tab and add CustomerPortal_Detection to XML Detection List. Click Save.

Note: Make sure that your detection group is not shadowed by any other existing target group by changing the Detection order as required. Let’s say we created another target group (CustomerPortal_Detection_01) using only cp:env and cp:entity targets. This new target group should be placed after CustomerPortal_Detection target group in the order, unless CustomerPortal_Detection target group will never be reached during a detection since it is shadowed by CustomerPortal_Detection_01.

Adding the Target Group to XML Detection List

10. Close the Detections Window and go back the Partner Administrator.

Now you are ready to use this newly created XML Detection Target Group in your Partner Agreements.

Creating a Partner Agreement Using XML Detection

1. Create a new Partner Agreement.

2. In Detection Tab under XML Detection Click on CustomerPortal_Detection.

3. Then put Target Values for each XML target of the Target Group. In this case we need trigger current Partner Agreement for the New Customer Order Creation request. Therefore, according to the  format of Customer Order Creation Request, cp:entity and cp:operation should be set to CustomerOrder and Create respectively.

Set Target Values

4. In Body Element Xpath, you can define which part of the input XML should be used in XML Transform process (This will be discussed in the future). In this case, I need only the content in RequestBody node. Therefore, I will put /CustomerPortalRequest/RequestBody as the Body Element Xpath and click Save.

Body Element Xpath

5. Add Archive and Send processes in Processes tab (refer the previous post). Drop the attached XML file in to the input channel that we configured in one of the previous posts.

Note: If XML Detection is used, it is not important to which input channel the input files are dropped. If MEC can find a agreement with correct XML Target Values, it will be triggered.

In the next post we will see how to update M3 using the messages coming from external applications.

Have a nice day…

MEC Part 3 – Creating a New Partner Agreement (with Channel Detection)

In my previous 2 posts we learnt how to set up receive (input) and send (output) channels. We are using an integration between a 3rd party customer portal and M3 as the scenario for this article series as I mentioned in my very first post on MEC.

The first integration point of that integration is Creating the Customer Order in M3 based on the details coming from Customer Portal. Let’s assume that Customer Portal is sending this XML as request to create the Customer Order in M3. Now we will drop this XML file in to the receiving channel we created (CustomerPortal\Inbound) and see what happens. As soon as the XML file is dropped in to the receiving channel, MEC picks up that file and the file gets disappeared. Now we can monitor, what has happened to that file in LCM.

Monitoring MEC Messages
  1. Go to LCM → MECDEV → Manage Application.

2. In Grid Management Pages, go to Message Tab.

3. The state of the last message that MEC has received is “Detect Failed”.

Detect Failed

4. We will go inside this message to see the input file that caused this error and make sure that it is the file that we just dropped in. Click on Show link in the message.

5. In Message Details page click on view button to see the .rcv file. This will show you the XML file that has triggered this MEC message.

View Message

You get this Detect Failed error when MEC does not know what to do with the file that it has received. That is why we need to create a Partner Agreement, to tell MEC what to do when a file is received.

Setting up a Partner Agreement with Channel Detection
  1. Go to Partner Administrator.

2. Right click on the Partner Agreement Pane and click on Insert Group. Give group a name (Customer Portal)

Insert Group

3. Right click on the newly created agreement and click on New Agreement.

Create New Agreement

4. Once the new agreement is added, change the basic details of the agreement.

Basic Agreement Details

5. Then go in to Detection Tab. In Detection tab we define how a MEC agreement identifies if it should be triggered when a request comes in to MEC.

6. In this case we will use Channel Detection. For that click on Channel Group under Channel Detection. Then select the receiving channel you need from the list. In this case it is Customer Order Inbound channel. What this means is, whenever a file is dropped in to CustomerPortal\Inbound folder, this MEC agreement is triggered.

Channel Detection

7. Once the detection method is set, go to Processes tab. This is where we define what to do when this partner agreement is triggered. Here we are not going to perform any complex tasks, but to archive the received message and send the same file in to the output folder we created.

8. To add the Archive Process, right click on the Processes box and select Archive.

Archive Process

9. To save the file from the previous process in to output folder, add Send Process. In the Configuration for Send window, select the relevant Send Channel and set the encoding method for the output file.

Send Process

10. Now your process tab should look like below.

List of Added Processes

11. Save the Partner Agreement and restart MEC component from LCM.

12. Once MEC component is restarted, go in to the Message details that had previously failed and click on Redetect or drop the XML request again into input folder.

13. Then check the MEC Messages in LCM, and this time the state should be “Finished”. Further, you will be able to see which agreement has picked up this message.

New Mec Message

14. In the output folder you should see a new XML file which has been created by the send channel. If you open that file, you will notice that it is similar to the input XML, because we directly sent the input file to the send channel.

In the next post we will discuss about a different detection method.

Have a nice day…