Search code examples
c#.netwcf.net-4.0wcf-client

WCF MessageHeaderArray not working correctly


I have a relatively simple service that takes in a Message contract for uploading a file. Because it is a file upload, only the file stream can be in the message body so I am using the message header for meta data.

My problem is that although I've added a string[] as a MessageHeaderArray when I add a service reference to the service in a test web app client, the variable has been generated as just a string.

Here is part of my MessageContract:

[MessageContract]
public class FileInformation : IDisposable
{
    [MessageHeader(MustUnderstand = true)]
    public string FileName { get; set; }

    [MessageHeaderArray]
    public string[] RequiredEntityNames { get; set; }

    [MessageHeaderArray]
    public string[] RequiredEntityIds { get; set; }

    [MessageHeader(MustUnderstand = true)]
    public string EntityName { get; set; }

This is driving me mad and I have spent almost a day trying to figure out what's going on. Any ideas on why the RequiredEntityNames and RequiredEntityIds are being generated as string instead of string[]?


Solution

  • Have you tried with "MessageHeader" attribute on arrays instead of "MessageHeaderArray" ?

    MSDN, "Using Arrays Inside Message Contracts" : http://msdn.microsoft.com/en-us/library/ms730255.aspx