Search code examples
biztalkpipelinebiztalk-orchestrations

Catching Exception in Pipeline Validation in BizTalk Orch


I'm doing a proof of concept on catching validation error in an orchestration. Eventually, we might want to map them back to a response message.

I created a expression shape that calls a Receive Pipeline with Validation (as desribed here: https://learn.microsoft.com/en-us/biztalk/core/how-to-use-expressions-to-execute-pipelines).

It's in an atomic scope, which has a Compenation handler, but no Exception handler. The pipeline blew up on validation, and ended the orchestration. How can I capture this and look at the data it generates? Eventually, I will try this component which catches multiple exceptions:

rcvPipelineOutputMsgs1 = 
 Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline
(typeof(Myapp.Pipelines.ValidateAtlastRequestPipeline), msg_In);

The error was written to the eventlog. The data is wrong, and I want to get an error, but I want to catch it.

Shape name: Call Validation
ShapeId: efe2529a-acaa-416b-ad8e-c3faef9624c5
Exception thrown from: segment 2, progress 3
Inner exception: There was a failure executing pipeline "Myapp.Pipelines.ValidateAtlastRequestPipeline". Error details: "The XML Validator failed to validate.
Details: The element 'LtlTenderRequest' has invalid child element 'DocumentName'. List of possible elements expected: 'Tenders'.. ".

Exception type: XLANGPipelineManagerException

enter image description here


Solution

  • Put the Atomic Scope (required to execute the PipelineManager) in a Long Running Scope (and Orchestration) with a Exception Handler. You don't need the Compensation Block at all.

    You should be able to catch the XLANGPipelineManagerException directly, or just Exception.