Thursday, July 13, 2006 6:45 AM
How to use Soap Headers in WCF? The samples using MessageContractAttribute doesn't help to solve this.
Thursday, July 13, 2006 3:17 PM
Two main ways.
- Contractually specified headers are done using the MessageHeaderAttribute for a MessageContractAttribute-created service.
- Headers not part of the contract can be added to the headers properties of the OperationContext on either side. Outbound headers need to have a new OperationContextScope created in order to set the headers.
Does this answer your question? Note that this model is different than the ASMX one. There is no attribute that you put on top of an operation to specify adding a specific header with a default value. Instead, if you care about headers you should create a MessageContractAttribute-based service contract, and then headers are directly part of the OM.
Does this help?
- Proposed As Answer by beduin4 Thursday, April 23, 2009 10:41 AM
Thursday, July 13, 2006 6:12 PM
Here's a sample of the second method inside a Client MessageInspector.
Thursday, January 25, 2007 9:40 PM
I like the idea but it throws error when I try to run that sample.
"Cross-thread operation not valid: Control 'txtRequest' accessed from a thread other than the thread it was created on."
Thursday, January 25, 2007 9:46 PM
Tuesday, January 30, 2007 4:41 PM
I have tried to follow your example and I could not be able to see the message which sends from client to the server. The only different between your example and my example is I use app.config file. I think I may miss something on my App.Config file at <EndpointBehavior> attribute section. If you have to use app.config file then what you put on <EndpointBehavior>?
Friday, June 13, 2008 6:49 AM
Using this http://www.codeplex.com/WCFExtras you can write the following code:Code Snippet
[SoapHeader("MyHeader", typeof(Header), Direction = SoapHeaderDirection.In)]
Tuesday, December 14, 2010 3:53 PM
thank eyalp and also codeplex! That work very well.
Wednesday, December 22, 2010 5:31 AM
Can anybody provide me the code sample having used [SoapHeader("MyHeader", typeof(Header), Direction = SoapHeaderDirection.In)]
Your help will be highly appreciated. Thanks