views:

101

answers:

1

I have a WCF Service Reference to a WSDL file for a credit card processing web service (Cybersource). I'd like to somehow extend the generated service reference client to implement IEnlistmentNotification as to support transactional processing.

I am familiar with implementing the IEnlistmentNotification interface, but I can't find a good extension point to catch anytime a service method is called such that I can maintain the state of the transaction enlistment.

For instance, the WSDL for Cybersource is here:

https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.48.wsdl

It has only one method "runTransaction". Ideally I'd intercept calls to this method, view the payload contents, determine enlistment actions, let the call continue, then examine the result to record information that I'd need to rollback the transaction. I'd probably capture the "transaction reference number" in a return result. Then on rollback do a cancel/credit/etc. By making this behave as part of an IEnlistmentNotification interface, I can make it extremely simple for others to use this class as part of a transaction.

I know that I could write a wrapper or a factory for the class, and that's how I'll proceed for now. However, I expect that WCF have an extension point that I can use to intercept the method calls - that I can directly perform on a partial version of the generated client class.

I expected the partial class generated to have partial method calls for tapping in, or events, but it has nothing of the sort (unless I'm missing something...).

+1  A: 

WCF does have one extension point that allows you to hook into the client to inspect data coming out and in, it's IParameterInspector, I wrote about them a while ago here. Not sure if it's what you need, but might be useful.

tomasr