SOAP Headers

Apr 22, 2014 at 11:02 PM
I tried to use WCFExtras to pass a custom type as header to a WCF service written in .Net 4.5. I tried to change the service first and so updated the service contract's only method as follows:

Imports SSNVerificationDataContracts
Imports WCFExtras.Soap
Public Interface ISsnVerificationService
<SoapHeader("MyHeaderData", GetType(MyServiceHeader))>
Function VerifySSN(ByVal ssnData As SSNData) As Boolean
End Interface

The header type is defined as follows:

Imports Microsoft.VisualBasic
Imports System.Runtime.Serialization
Public Class MyServiceHeader
Public HeaderData As Person
End Class

Before changing the WCF client code, I updated service reference to the 'SSN verification' service. Now the VerifySSN takes two parameters: the header and the SSN string. This is not what I was trying to do. Also, this is different from the WCFExtras code samples. The SOAP Header should not become additional parameter to the WCF operation. Please let me know how I can pass the SOAP header the way it is described in the sample WCFExtras client.

Thanks in advance for your help.
Apr 22, 2014 at 11:40 PM
Edited Apr 22, 2014 at 11:40 PM
Just to eliminate the possibility of incompatible .net versions, I opened the WCF extras solution in VS 2012 and changed the target framework of each Visual Studio project to .net 4.5. Then I removed and readded all references to WcfExtras.dll. Same result.
Apr 23, 2014 at 6:23 PM
I looked at my configuration files on WCF service as well as WCF client and found that I was missing a few configuration elements. So my WCF client is now able to send a SOAP header and the header is received in the service operations. I am still a bit concerned to see that most of the posts on this forum are more than 5 years old.
May 8, 2014 at 12:08 AM
@shekharsh, have a look at WCFExtras+. It is a version of WCFExtras that has been kept more up-to-date.

I have been working on creating a new version of WCFExtras+ with support for .NET 4.5. I actually ran into the same issue you had when testing with 4.5. Can you describe what config elements you were missing?
Jul 1, 2014 at 10:35 PM
Edited Jul 1, 2014 at 10:36 PM
I was missing the following configuration in the client app.config.
          <extension type="WCFExtras.Soap.SoapHeaderImporter, WCFExtras" />