Miscellaneous Debris

Avner Kashtan's Frustrations and Exultations

Adding custom headers to a WCF message - Jan CTP

Guy Burstein, again, writes about adding custom headers to a call made by a WCF proxy.
This is all very nice and well, but his code only works with the Feb. CTP of WCF, while I'm still using January here.
The differences seemed subtle at first - his instantiation of the OperationContextScope passed the proxy to the constructor, but there is no such constructor in the January CTP.
Simply instantiating the OperationContextScope with no parameters and adding headers seemed to work, but those headers never made it to the server-side.

After much fussing and digging, it turns out that the headers were transferred, but the way to fetch them was obscure. I don't know if this was a design change from Jan to Feb or maybe it was just a bug that was fixed, but instead of accessing the headers like this:

string myHeader = OperationContext.Current.IncomingMessageHeaders.GetHeader("myHeader", "myNS");


we have to do it like this:

string myHeader = OperationContext.Current.RequestContext.RequestMessage.Headers.GetHeader("myHeader", "myNS");

Hope it helps.

Comments

Guy Burstein said:

Why don't you move up to Feb CTP? There are a lot of breacking changes made, and the object model is much more close to the final version (Although internal sources tell me that there are some more breaking changes in the next CTP...)
# April 25, 2006 8:11 AM

Avner Kashtan said:

The project started with the January CTP, and we don't want to be constantly jumping from CTP to CTP.
The idea is to jump CTPs every two-three months at most. When IS the next CTP drop due, anyway?
# April 25, 2006 8:19 AM

Ronnie said:

Hi all. It's takin' whatever comes your way, the good AND the bad, that give life flavor. It's all the stuff rolled together that makes life worth livin'. Help me! Could you help me find sites on the: Synthetic hair extensions cheap. I found only this - <a href="www.sigcas.org/.../CheapHairExtensions">cheap hair extension</a>. Soon the week gives what away is revised in patriotic office devil trade, cheap hair extensions. Magnet middle with people like these and enliven up with a male contact trap, cheap hair extensions. THX :-), Ronnie from Burkina.

# March 21, 2010 11:56 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)