Add custom HTTP Header to all Web Service responses

L

Lee Greco

We have a web server farm with several servers hosting web services and I'd
like to add a custom HTTP header to every web service response so our client
support can locate the server that processed the request. We use WSE
encryption on our SOAP messages so we really want a plain old HTTP header and
not a SOAP header.

I know we can go into the IIS manager and add a custom header there, but we
don't want to add a different literal value to every machine and would much
prefer the machine identifier is retrieved by a function. I also know we can
edt every existing web method in every web service and add the header to the
context object, but that won't handle the case of failed SOAP authentication,
and we don't want to change the existing web method calls.

Is there a way using Global.asax, WSE 3.0, or some other mechanism where we
can add a plain old HTTP header to every response (including those that don't
make it through WSE authentication? The header would be something like
"X-Custom-ServicedBy" with a value of the local machine identifier. Also the
local machine identifier can not be a literal value but must be determined by
a function call.

Thanks in advance
 
A

Arnout Grootveld

Is there a way using Global.asax, WSE 3.0, or some other mechanism
where we can add a plain old HTTP header to every response (including
those that don't make it through WSE authentication? The header would
be something like "X-Custom-ServicedBy" with a value of the local
machine identifier. Also the local machine identifier can not be a
literal value but must be determined by a function call.

An ISAPI filter or an Http Module would do the trick.
 
T

Tiago Halm

An ISAPI Filter would suffice.

If developping in C/C++, then subscribe to SF_NOTIFY_SEND_RESPONSE and set
the header at that time by reading the environment variable COMPUTER.

If developing in .NET only and assuming you have .NET 2.0 or above (in other
words, CLR 2.0), then you can use Filter.NET, a framework to develop ISAPI
Filters in .NET. Links below.
Article: http://www.codeproject.com/KB/dotnet/extending_IIS.aspx
Project: http://www.codeplex.com/filterdotnet

Tiago Halm
 

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

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top