Amlan Chakraborty - MSFT

I would like to kick off this forum with the following question.

How would you enable BAM interception when your WCF service uses unmatched message handlers What is your filter going to look like in the abscence of specific operation names

Bring your answers in !!

- Amlan




Re: BizTalk Interceptors Kick off question -- WCF BAM interception for unmatched message handlers

Keith Lim

In normal filtering for WCF BAM interception, the Filter node of the interceptor configuration (IC) file would contain:

  • the call point (e.g. if this is sevice, it would either be ServiceRequest or ServiceReply)
  • the operation name

as in the example below:

<ic:Filter>

<ic:Expression>

<wcfSurpriseperation Name="GetServiceContractCallPoint" />

<icSurpriseperation Name="Constant">

<ic:Argument>ServiceRequest</ic:Argument>

</icSurpriseperation>

<icSurpriseperation Name="Equals" />

<wcfSurpriseperation Name="GetOperationName" />

<icSurpriseperation Name="Constant">

<ic:Argument>AuthorizeWithDataContract</ic:Argument>

</icSurpriseperation>

<icSurpriseperation Name="Equals" />

<icSurpriseperation Name="And" />

</ic:Expression>

</ic:Filter>

However, in the case when the service is using a unmatched message handlers, the filter would need to be filter by the action.

<ic:Filter>

<ic:Expression>

<wcfSurpriseperation Name="GetServiceContractCallPoint" />

<icSurpriseperation Name="Constant">

<ic:Argument>ServiceRequest</ic:Argument>

</icSurpriseperation>

<icSurpriseperation Name="Equals" />

<wcfSurpriseperation Name="XPath">

<wcf:Argument>//s:Envelope/s:Header/a:Action/text()</wcf:Argument>

</wcfSurpriseperation>

<icSurpriseperation Name="Constant">

<ic:Argument>http://Microsoft.BAMWCFInterceptor.Test/ITxn/ClientOperation1</ic:Argument>

</icSurpriseperation>

<icSurpriseperation Name="Equals" />

<icSurpriseperation Name="And"/>

</ic:Expression>

</ic:Filter>

Or to simplify the above, in case, you don't want to spell out the whole action including the namespace, you can use the XPath contains command such illustrated as below:

<ic:Filter>

<ic:Expression>

<wcfSurpriseperation Name="GetServiceContractCallPoint" />

<icSurpriseperation Name="Constant">

<ic:Argument>ServiceRequest</ic:Argument>

</icSurpriseperation>

<icSurpriseperation Name="Equals" />

<wcfSurpriseperation Name="XPath">

<wcf:Argument>contains(//s:Envelope/s:Header/a:Action/text(),"ClientOperation1")</wcf:Argument>

</wcfSurpriseperation>

<icSurpriseperation Name="And"/>

</ic:Expression>

</ic:Filter>






Re: BizTalk Interceptors Kick off question -- WCF BAM interception for unmatched message handlers

Dwight Goins

You could also filter by the content within the message, especially when the message is a response message, like this:

(It's cheesy I know...)

Code Snippet

<bam:OnEvent IsEnd="true" Name="WCF_OrderShipped_Response" Source="WCF_Service_OrderShipment">
<bam:Filter>
<bam:Expression>
<wcf:Operation Name="GetServiceContractCallPoint" />
<bam:Operation Name="Constant">
<bam:Argument>ServiceReply</bam:Argument>
</bam:Operation>
<bam:Operation Name="Equals"/>
<wcf:Operation Name="XPath" >
<wcf:Argument >//s:Body/*[local-name()='ShipServiceResponse' and namespace-uri()='http://QuickLearn/Demo/Services']/*[local-name()='ServiceData' and namespace-uri()='']/*[local-name()='recordBamActivity' and namespace-uri()='']</wcf:Argument>
</wcf:Operation>
<bam:Operation Name="Constant">
<bam:Argument>true</bam:Argument>
</bam:Operation>
<bam:Operation Name="Equals"/>
<bam:Operation Name="And" />
</bam:Expression>
</bam:Filter>