Complex Message Configuration Scenarios

The Connector you develop using the Messaging Framework must be able to parse messages received from the sending API. To parse the message, the Connector must understand the data structure for each message object. You can use a sample message from the sending API to configure the code that parses the inbound message by pasting the sample message as JSON in the item.cs file in your project and modifying the Connector.cs file to match the changes in item.cs. See Creating Message Classes for step-by-step instructions on pasting a message into your project.

These more complex scenarios work using the same mechanisms as the simpler scenarios, but the functions that go from the first type to second type are more complex. For these we include the JSON, the fixed up .NET classes, and the registration code.

If the message or container from the sending API is an array, the JSON message may look like this: 

 

 [
    {
        "AccountName""Acme, Inc.",
        "Contacts": [
            {
                "FirstName""Abby",
                "LastName""Aaron"
            },
            {
                "FirstName""Bob",
                "LastName""Burr"
            }
        ]
    },
    {
        "AccountName""Abc, Inc.",
        "Contacts": [
            {
                "FirstName""Andy",
                "LastName""Zander"
            },
            {
                "FirstName""Beth",
                "LastName""Yaker"
            }
        ]
    }
]

If you paste JSON as Classes in item.cs you start with:

public class Rootobject
{
    public Class1[] Property1 { get; set; }
}
public class Account
{
    public string AccountName { getset; }
    public Person[] Contacts { getset; }
}
public class Person
{
    public string FirstName { getset; }
    public string LastName { getset; }
}

You also need to modify the Connector.cs file to recognize the changes made in the item.cs file:

protected override IDictionary<string, MessageDescription> RegisterEntities()
{
    return this.Start
        .RegisterArray<Account[], Person>
        (accounts => accounts
        .SelectMany(account => account.Contacts));
}

See

Building A Messaging Framework Connector