Centralize SOAPHeader Processing?

Centralize SOAPHeader Processing?

am 17.04.2008 07:41:12 von Spam Catcher

Hi all,

In an ASP.NET web service, is there a way I can centralize processing of
SOAP Headers?

Currently I need to nput my header logic into each webmethod - is there an
event, mechanism, extension, etc I can hook into to do all my processing
before the webmethod is executed?

Thanks!

--
spamhoneypot@rogers.com (Do not e-mail)

Re: Centralize SOAPHeader Processing?

am 21.04.2008 20:47:24 von John Saunders

"Spam Catcher" wrote in message
news:Xns9A83112EB8527usenethoneypotrogers@127.0.0.1...
> Hi all,
>
> In an ASP.NET web service, is there a way I can centralize processing of
> SOAP Headers?
>
> Currently I need to nput my header logic into each webmethod - is there an
> event, mechanism, extension, etc I can hook into to do all my processing
> before the webmethod is executed?

There's no general way to do this. However, you can apply various design
patterns to save some effort.

I don't know a name for the following pattern, but here's what I did for one
web service. I abstracted the web methods into classes. Each web method had
its own little class. I was then able to consider what was in common among
several of the classes - for instance, header processing. That which was in
common got moved into a base class.

This left my .ASMX.cs file as nothing more than a façade. Each web method
simply instantiated the corresponding "service layer" class, passing the web
method parameters into the constructor call. It then called the "Execute"
method of the class. Execute was a method on the base class. It called a
virtual PreProcess method, then a virtual ExecuteImplementation method, then
a virtual PostProcess method. Certain derived classes would override
PreProcess (for instance, to process a particular set of SOAP Headers), and
ExecuteImplementation to impose a common processing pattern.

This allows specialization of classes to correspond to specialization of
behavior.

This was also done in a bit of a hurry. I'm sure others can do better.

--
------------------------------------------------------------ --------------------
John Saunders | MVP - Windows Server System - Connected System Developer