GISB Message Validation from a Custom Pipeline Component
Introduction
The GISB Receive adapter will perform some basic checks on incoming messages to validate that to, from, etc. are specified. In some cases additional validation logic must be applied to in the incoming message. This article demonstrates how to perform this additional validation from within a custom pipeline component.
Contents
Overview and Settings
By default, when receiving a message the adapter will process it and return a response to the sender before submitting the message to BizTalk. The adapter will perform some basic checks on the message and will automatically return the following error responses if applicable:
EEDM699: Decryption Error";
EEDM604: The signature could not be verified.
EEDM113: Invalid "receipt-security-selection"
EEDM100: Missing "from" Common Code Identifier code
EEDM101: Missing "to" Common Code Identifier
EEDM102: Missing input format
EEDM103: Missing data file
In the case where additional error conditions must be checked for, the adapter can be configured to use a value set
by a custom pipeline component instead of automatically responding.
First, set the Other property of the adapter to include SendResponseBeforeSubmit=False. This tells the adapter to wait before sending the response until after the message was submitted to BizTalk and allows the custom pipeline to execute its validation logic and supply a request status to be returned.
The next section describes how to obtain and validate information from within a custom pipeline component.
Message Context Properties
Every incoming message will have context properties corresponding to fields in the request. In addition there is a context property called GISBRequestStatus. This is populated with the results of the checks done by the adapter, and may be set from within the custom pipeline component to indicate the results of any additional validation. If checks are successful this value should be "ok".
Below is an example of message context properties on an incoming message. Properties like "to", "from", "input-format", "receipt-disposition-to" correspond directly to the fields specified in the incoming message.
The Pipeline Component Code
In this section the relevant code to read values from the message context from inside a custom pipeline component is provided. For a complete project that can be compiled and deployed please download the example project. This is meant only as an example and additional logic/code should be added in a real project.
private static string GISBNameSpace = "http://schemas.nsoftware.com/BizTalk/Adapters/2024/GISB";
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
{
if (pContext == null)
{
throw new Exception("Cannot decode message: missing pipeline context.");
}
if (pInMsg == null)
{
throw new Exception("Cannot decode message: message cannot be null.");
}
IBaseMessageContext context = pInMsg.Context;
if (context != null)
{
string sRequestStatus = (string)context.Read("GISBRequestStatus", GISBNameSpace);
//The GISB Adapter will check for some conditions automatically, such as a missing to element.
//If the status is "ok" initial checks have passed and additional checks can be performed.
if (sRequestStatus == "ok") //Initial checks passed. Perform more checks.
{
//Check input-format
object oInputFormat = context.Read("input-format", GISBNameSpace);
if (oInputFormat == null) //Validate that input-format is present
{
sRequestStatus = "EEDM102: Missing input format";
}
else //Validate that input-format has the right value
{
string sInputFormat = (string)oInputFormat;
if (sInputFormat != "X12")
sRequestStatus = "EEDM107: Invalid input format";
}
//Check transaction-set
object oTransactionSet = context.Read("transaction-set", GISBNameSpace);
if (oTransactionSet == null) //Validate the transaction-set is present
{
sRequestStatus = "EEDM104: Missing transaction-set";
}
else //Validate that transaction-set has the right value
{
string sTransactionSet = (string)oTransactionSet;
if (sTransactionSet != "G873NMST")
{
sRequestStatus = "EEDM105: Invalid transaction-set";
}
}
}
pInMsg.Context.Write("GISBRequestStatus", GISBNameSpace, sRequestStatus);
}
return pInMsg;
}
This code would be used inside a custom pipeline component. The project should then be compiled and the pipeline component used within a Receive Pipeline project in the Validate stage. Deploy the pipeline and configure the Receive Location to use your pipeline.
The example project is a project that can be compiled used as reference for a real project.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.