Centralize SOAPHeader Processing?

G

Guest

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!
 
J

John Saunders

Spam Catcher said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top