[Mono-bugs] [Bug 598223] New: Custom MessageHeaders not being sent

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 20 14:15:40 EDT 2010



           Summary: Custom MessageHeaders not being sent
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: x86
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: WCF
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: richard at ayudasystems.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Third Party Developer/Partner
           Blocker: Yes

Description of Problem:

Custom headers attached to WCF messages are not sent when running in Mono 2.6
on both Windows and Linux.

Steps to reproduce the problem:

Create a simple WCF service exposing a single method. The parameter should be
an object with the MessageContract attribute, and contain a header. Example:

public interface IRegularService
    void GetData(TestRequestMessage obj);

public class TestRequestMessage
    public string Header { get; set; }

    public string Body { get; set; }

public class RegularService : IRegularService
    #region IRegularService Members

    public void GetData(TestRequestMessage obj)
       if (obj.Header == null)
           throw new Exception("Header is null");
           System.Diagnostics.Debug.WriteLine(string.Format("Header: {0}",

       if (obj.Body == null)
           throw new Exception("Body is null");
           System.Diagnostics.Debug.WriteLine(string.Format("Body: {0}",



Host the service and then attempt to call it from a Mono client:

.. client code:

BasicHttpBinding binding = new BasicHttpBinding();
ServiceEndpoint svcEp = new
                        binding, new

ChannelFactory<IRegularService> cnlFactory = new

IRegularService svc = cnlFactory.CreateChannel();

TestRequestMessage msg = new TestRequestMessage()
    Header = "header",
    Body = "body"


Actual Results:

The custom header is not passed to the service. Break into the service and the
'Header' property will be null.

Expected Results:

The custom header should be passed to the service as part of the message.

How often does this happen? 

Every time.

Additional Information:

As well as using the MessageContract / MessageHeader attributes, I also tried
to attach a header to the message manually, e.g.

using(OperationContextScope scope = new
    MessageHeader<string> mhg = new MessageHeader<string>("header");
    MessageHeader untyped = mhg.GetUntypedHeader("token", "ns");


And then read it back on the service like this:

string token =


The result was the same.

I also implemented IClientMessageInspector on the client, and attached it to
the endpoint using an IEndpointBehavior implementation. In my
IClientMessageInspector implementation, I used the BeforeSendRequest method to
attach my custom header to the message and then check it was added succesfully.
My header appears in the message, however it does not get sent to the server
(it is null on the server).

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list