BizTalk Tips & Things

Agustin Mantaras BizTalk Blog

The SOAP Adapter does not returns a validation exception to a subscribed orchestration

Because there are many customers still using the deprecated SOAP adapter i have decided to create this post in order to help them in this particular situation.

 

Consider the following scenario:

 image

 

The orchestration has a subscription through the web port.  There is a strong business requirement to validate all the incoming messages, within the response cycle, against an schema already knew by BizTalk (deployed in the Management DB) . Typically, to accomplish this task, we need to create a receive pipeline that validates the incoming message and assign the document schemas property of the XML validator component with the desired deployed schema (s).

 

image 

 

Well, in this case, what would be the expected  behavior if a validation error is found during the validate stage? if not using the SOAP Adapter,  the pipeline will throw  a validation exception that subscribed orchestration will catch. Unfortunately, in case of the SOAP adapter this will not happen never and the message will get into the orchestration, with validation errors included, causing a following map to fail with no control at all.

Right, but why?

The SOAP Adapter will not cause an exception back to an orchestration when the associated pipeline is getting a validation exception. This has been addressed in previous version of BizTalk with the WSE Adapter and recently by the WCF Adapters. The recommendation in here, if possible, is to move to WCF.

If you have no choice to move to WCF you can do the following:

The proposed walkthrough:

We are going to take advantage of the feature for executing inline pipelines introduced early in BizTalk 2006.

The idea is simple: Validate the message inside a scope that has a exception block configured to catch the validation exception.

 

image

 

Steps to execute the Receive Pipeline

#1# First of all, you need to add the following references to the BizTalk Project:

  • Microsoft.XLANGs.Pipeline  typically located on C:\Program Files (x86)\Microsoft BizTalk Server 2006\Microsoft.XLANGs.Pipeline.dll
  • Microsoft.BizTalk.Pipeline   typically located on  C:\Program Files (x86)\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Pipeline.dll

#2# Create the Atomic Scope ValidateMessage

#3# At ValidateMessage level, create the InputPipeline variable  as Microsoft.XLANGs.Pipeline.ReceivePipelineOutputMessages type

#4# Insert an expression shape and add the calling code:

InputPipeline = Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(MyNameSpace.MyProjectName.MyReceivePipelineName),MsgIn);

where MsgIn is the message you are expecting to come through the web service response (the one you have to set up in the receive shape)

#5# Customize the exception block with your own requirements.

In this case the exception information is saved in temp variables to use them later by tracking the values in BAM