Transco V2
Integration scenarios often need to 'promote' or 'enrich' messages/data from external stored systems. Codit is a long-term implementer of something called 'Transco', which was previously a BizTalk component, but is now been required in modern Azure Logic Apps integrations.
Invictus provides a Transco component to promote properties from a database, by using the content or context to create the SQL query which will be executed against the specified table. Transco can also perform transformations on XML content by simply specifying the XSLT file from storage (Transco supports XSLT 1.0 syntax.).
Available endpoints
-
/api/TranscoXML
: used with XML content. A Transco config file is used to list the instructions necessary to promote values from an SQL database or to transform the content via an XSLT file. -
/api/TranscoJson
: used with JSON content. A Transco config file is used to list the instructions necessary to promote values from an SQL database. Transformations cannot be performed on JSON content. -
/api/MatrixBasicPromote
: accepts a simple list of parameters and promotes them to theContext
in the response.
- XML/JSON
- Matrix basic promote
The Transco request requires following values:
- XML/JSON content in BASE 64 format;
- Context as key-value pair list;
- Name of Transco config file in Azure Blob Storage.
Full request body JSON example
// POST /api/TranscoXML
// POST /api/TranscoJson
{
"Content": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTE2Ij8+PHJvb3Q+PG5hbWUgc3RhdHVzPSJNZW1iZXIiPkpvaG4gRG9lPC9uYW1lPjwvcm9vdD4=",
"Context": {
"CustomerActive": "true"
},
"TranscoConfig": "docs_config.json"
}
Full response body JSON example
// 200 OK <- /api/TranscoXML
// 200 OK <- /api/TranscoJson
{
"Content": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTE2Ij8+PE1lbWJlcj5Kb2huIERvZTwvTWVtYmVyPg==",
"Context": {
"CustomerActive": "true"
},
"TranscoConfig": "docs_config.json"
}
Transco config file
A JSON Transco config file is required to specify details about the instruction which will be performed. Instructions are executed in the order in which they appear. The name of the config file should be specified in the request so that it can be retrieved from the storage account.
- SQL Commands
- XML Transformation
Transco can execute SQL commands to promote properties from a specified database and table. The connection to the database can be achieved via either a raw connection string or the name of an Azure Key Vault secret.
The parameters of the SQL query can be populated from 3 sources:
- XML/JSON request content via XPath/JPath
- Request context
- Fixed value
The SQL query result will inserted at the specified destination
XPath or JPath. For XPaths ending at an attribute, e.g. /persons/person/@name
, the value will be inserted in that attribute. Otherwise, it will be inserted in the inner text.
- A
scopePath
can be defined so that the command affects only nodes within that path. - A connection to the SQL database must be provided (via a connection string in plain text or in an Azure Key Vault secret).
- Parameters in the SQL query must be denoted with an
@
symbol. Parameters may be given a name or indexed with a number.SELECT CustomerStatus FROM dbo.Customers WHERE CustomerName = @Name AND Active = @Active*
-- or
SELECT CustomerStatus FROM dbo.Customers WHERE CustomerName = @1 AND Active = @2*
Transformations can be performed on XML content. The name of the XSLT file in the storage account is required for this operation.
This instruction can be added to the Transco Config to transform XML content via the specified XSLT file. Any required assemblies and dependencies used by the transformation can also be specified, while the respective DLL files are to be in the storage account.
This instruction is only available when calling the /TranscoXML
endpoint.
{
"xsltTransform": [Name of XSLT file],
"extensions": [
{
"namespace": [Assembly namespace],
"assemblyName": [Assembly name],
"className": [Assembly class name],
"dependencies": [
"[DLL dependency file name]",
"[DLL dependency file name]"
]
}
]
}
All required files are to be saved in an Azure Storage Account and in a Blob Storage container with the name: Transcov2configstore
(This container is automatically created by Invictus):
/Configs
folder with Transco config files/XSLTs
folder with transformation files/Assemblies
folder with assembly and dependency DLL files
Full Transco config file specification
{
"instructions": [
{
"scopePath": [XPath/JPath of content scope],
"namespaces": [
{
"namespace": [XML Namespace],
"prefix": [XML Namespace prefix]
}
],
"destination": [XPath/JPath of the results destination, or Context key if promoteToContext = true],
"promoteToContext": [If true query result is saved to Context at key destination],
"command": {
"databaseConnectionString":[Raw connection string to DB],
"databaseKeyVaultName": [Name of DB connection string secret in Key Vault],
"commandValue": [SQL query to be executed],
"isMandatory": [If true, will throw error when result is null],
"columnName": [Obtain value from specified column if query returns multiple fields. If empty, value from first column is obtained],
"defaultValue": [Default value of result],
"parameters": [
{
"paramName": [Name of param in query],
"value": [Type dependent. XPath or JPath if valueType = "path"],
"type": [SQL DB type. See: https://learn.microsoft.com/en-us/dotnet/api/system.data.sqldbtype],
"valueType": ["path" or "fixedValue" or "context"]
},
{
"paramName": [Name of param in query],
"value": [Type dependent. Any string value if valueType = "fixedValue"],
"type": [SQL DB type. See: https://learn.microsoft.com/en-us/dotnet/api/system.data.sqldbtype],
"valueType": ["path" or "fixedValue" or "context"]
},
{
"paramName": [Name of param in query],
"value": [Type dependent. Key to value in context if valueType = "context"],
"type": [SQL DB type. See: https://learn.microsoft.com/en-us/dotnet/api/system.data.sqldbtype],
"valueType": ["path" or "fixedValue" or "context"]
}
],
"cache": {
"useCaching": [If true, query result is cached],
"cachingTimeout": [Cache timeout timespan]
}
}
},
{
"xsltTransform": [Name of XSLT file],
"extensions": [
{
"namespace": [Assembly namespace],
"assemblyName": [Assembly name],
"className": [Assembly class name],
"dependencies": [
"[DLL dependency file name]",
"[DLL dependency file name]"
]
}
]
}
],
"options": {
"configCache": {
"useCaching": [If true, config file is cached],
"cachingTimeout": [Cache timeout timespan]
},
"indentResult": [If true, Transco results will be formatted and indented]
}
}
The basic promote is a simple way of promoting values to the context. This version accept a simple list of parameters and promotes them to the Context. Values are not required, any values not supplied will not be present in the response object and will be ignored.
Transco XML/JSON also supports promotion of values to the context. This is achieved by setting the promoteToContext=true
in the Transco configuration file. The destination
property must also be set to the key of the desired destination in the context. With these two properties, any result from the SQL operation is saved to the context.
Supported request parameter | type |
---|---|
KeyValueCollection | Key-Value collection (each pair is individually promoted) |
Flow | string |
Domain | string |
Service | string |
Action | string |
Version | string |
Sender | string |
ApplicationName | string |
Milestone | string |
ConversationId | string |
CorrelationId | string |
BatchId | string |
Data1 | string |
Data2 | string |
Data3 | string |
Full request body JSON example
{
"Content": "ew0KICAiQ291bnRyeUNvZGUiOiAiQkUiLA0KICAiTW9uZXkiOiAgeyAiQW1vdW50IjogIDUwLCAiQ3VycmVuY3kiOiAgIkdCUCIgIH0NCn0NCg==",
"Context": {
"x-conversationId": "29500405-d7cf-4877-a72b-a3288cff9dc0",
"x-correlationId": "fc13d345-ebd7-44f2-89a9-4371258c0a08",
"x-batchId": "975f7ea4-6247-431b-afb6-6d27fb47516f",
"x-applicationName": "InvoiceApp",
"filter": "endtoendintegrationtests"
},
"KeyValueCollection": {
"w": 3,
"l": 10.2,
"h": 1,
"t": 200,
},
"Flow": "fl1",
"Domain": "do",
"Service": "sr1",
"Action": "Ac",
"Version": "Vs",
"Sender": "Snd",
"ApplicationName": "Snd",
"Milestone": "2018",
"ConversationId": "29500405-d7cf-4877-a72b-a3288cff9dc0",
"CorrelationId": "29500405-d7cf-4877-a72b-a3288cff9dc0",
"BatchId": "29500405-d7cf-4877-a72b-a3288cff9dc0",
"Data1": "d1",
"Data2": "d2",
"Data3": "d3"
}
Full response body JSON example
{
"content": "ew0KICAiQ291bnRyeUNvZGUiOiAiQkUiLA0KICAiTW9uZXkiOiAgeyAiQW1vdW50IjogIDUwLCAiQ3VycmVuY3kiOiAgIkdCUCIgIH0NCn0NCg==",
"context": {
"x-conversationId": "29500405-d7cf-4877-a72b-a3288cff9dc0",
"x-correlationId": "fc13d345-ebd7-44f2-89a9-4371258c0a08",
"x-batchId": "975f7ea4-6247-431b-afb6-6d27fb47516f",
"x-applicationName": "InvoiceApp",
"filter": "endtoendintegrationtests",
"Flow": "fl1",
"Domain": "do",
"Service": "sr1",
"Action": "Ac",
"Version": "Vs",
"ApplicationName": "Snd",
"Milestone": "2018",
"Data1": "d1",
"Data2": "d2",
"Data3": "d3",
"Sender": "Snd",
"w": 3,
"l": 10.2,
"h": 1,
"t": 200
},
"conversationId": null,
"correlationId": null,
"batchId": "29500405-d7cf-4877-a72b-a3288cff9dc0"
}
Migrating Transco v1 to v2
Migrating Transco v1 to v2
We need to change the authentication and endpoint and remove the metadata links.
Also we need to change the Transco configuration files, for this you can use the migration tool from Codit's integration practice that can be found here.
"Transform_XML": {
"type": "Http",
"inputs": {
"method": "POST",
- "uri": "[parameters('invictus').Framework.Transco.v1.TranscoXmlUrl]",
+ "uri": "[parameters('invictus').Framework.Transco.v2.TranscoXmlUrl]",
"authentication": {
- "username": "Invictus",
- "password": "@parameters('invictusPassword')",
- "type": "Basic",
+ "identity": "[parameters('infra').managedIdentity.id]",
+ "audience": "[parameters('invictus').authentication.audience]",
+ "type": "ManagedServiceIdentity"
},
"body": {
"Content": "@triggerBody()?['Content']",
"Context": "",
"TranscoConfig": "EFACT_D96A_ORDERS-to-Generic_Order.json"
}
},
"runAfter": {}
}
Migrating Matrix v1 to Transco v2
The Matrix component's functionality has been placed in the Transco v2 API.
"Extract_Message_Context": {
"type": "Http",
"inputs": {
"method": "POST",
- "uri": "[parameters('invictus').framework.matrix.v1.basicMatrixUrl]",
+ "uri": "[parameters('invictus').framework.Transco.v2.basicMatrixUrl]",
"body": {
"Domain": "B2B-Gateway",
"Service": "@{concat('AS2-Receive-', body('Decode_AS2_message')?.aS2Message?.aS2To)}",
"Action": "@{outputs('Integration_Account_Artifact_Lookup_-_Get_SendingPartner')?.properties?.metadata?.PayloadFormat}",
"Version": "1.0",
"Sender": "@{outputs('Integration_Account_Artifact_Lookup_-_Get_SendingPartner')?.properties?.metadata?.PartyName}",
"Content": "@{base64(body('Decode_AS2_message')?.AS2Message?.Content)}",
"KeyValueCollection": {
"ReceiveFileName": "@{body('Decode_AS2_message')?['AS2Message']?['FileName']}",
"ReceiveProtocol": "AS2",
"ReceiveProtocolDetails": "@{body('Decode_AS2_message')?['AS2Message']?['AS2From']} > @{body('Decode_AS2_message')?['AS2Message']?['AS2To']}",
"ReceiveReference": "@{body('Decode_AS2_message')?['AS2Message']?['OriginalMessageId']}",
"ReceiveTimeUtc": "@{utcNow()}"
}
},
"authentication": {
- "username": "Invictus",
- "password": "@parameters('invictusPassword')"
- "type": "Basic",
+ "identity": "[parameters('infra').managedIdentity.id]",
+ "audience": "[parameters('invictus').authentication.audience]",
+ "type": "ManagedServiceIdentity"
}
},
"runAfter": {},
- "metadata": {
- "apiDefinitionUrl": "[parameters('invictus').framework.matrix.v1.definitionUrl]",
- "swaggerSource": "custom"
- }
}