I’m making WCF calls from a Mono client running on Ubuntu (Mono 2.6).
I can’t seem to add a custom header to my messages. I have tried two different ways:
- Using a [MessageContract] and [MessageHeader] attributes on a custom class
-
Adding the header to the outgoing messages programmatically, e.g.
MessageHeader mhg = new MessageHeader(“test”);
MessageHeader untyped = mhg.GetUntypedHeader(“token”, “ns”);
OperationContext.Current.OutgoingMessageHeaders.Add(untyped);
The header is not there when the call reaches the server! It’s always null.
Note that both methods work fine running on .NET in Windows. Also note that the message body gets through just fine on Mono.
I see some references online that suggest this should work:
http://forums.monotouch.net/yaf_postsm1692.aspx
https://bugzilla.novell.com/show_bug.cgi?id=551745
Also – the Mono status page shows that all the MessageHeader stuff is fully implemented…
Anyone had luck with this?
Thanks in advance, Richard
I’m struggling with similar issues.
I’ve solved the problem with a C# client and server. Assuming you’ve got the client side right, my experience might help:
My service method looks like this:
And my service method parameter class looks like this:
Note the Name= and Namespace= assignments within the attribute.
When I inject the message headers on the client side, I also specify the name and namespace . In C# it looks like this:
The result is that the named custom header I provide in the client is mapped to the similarly named (via attribute) property on the method parameter instance.