WCF - CODEGEN: Generating message contract since message FileRequest has headers

Posted by Tri Q on Stack Overflow See other posts from Stack Overflow or by Tri Q
Published on 2010-04-09T07:40:15Z Indexed on 2010/04/09 7:43 UTC
Read the original article Hit count: 605

Filed under:

I am aware that there is a similar question here with no solution.

I'm working on a WCF streaming service over HTTP.

Here are my MessageContract

[MessageContract]
public class FileRequest
{
    #region Message Header

    [MessageHeader(MustUnderstand = true)]
    public Credential Credentials { get; set; }

    #endregion

    #region Message body

    [MessageBodyMember(Order = 1)]
    public FileInfo FileInfo { get; set; }

    #endregion

    #region Ctor

    // ...

    #endregion

}

[MessageContract]
public class FileRequestResponse
{
    #region Message Header

    [MessageHeader(MustUnderstand = true)]
    public FileInfo FileHeader { get; set; }

    [MessageHeader(MustUnderstand = true)]
    public OperationResult<bool> OperationResult { get; set; }

    #endregion

    #region Message Body

    [MessageBodyMember]
    public Stream FileStream { get; set; }

    #endregion


    #region Constructor

    // ...

    #endregion

}

Here is my ServiceContract

[ServiceContract(Namespace = "https://service.contract.example.com")]
public interface IUpdateService
{
    [OperationContract(Action = "GetUpdates")]
    OperationResult<List<FileInfo>> GetUpates(ApplicationInfo applicationInfo, Credential credential);

    [OperationContract(Action = "GetFile")]
    FileRequestResponse FileRequest(FileRequest fileRequest);
}

Now the question is why I am getting this error:

// CODEGEN: Generating message contract since message FileRequest has headers

When I add my service reference. The end result is that the service contract wraps the FileRequest operation into a wrapper which I do not want.

public FileInfo FileRequest(Credential Credentials, FileInfo, out OperationResult<bool> OperationResult, out System.IO.Stream FileStream)

NOTE: I have not checked the "Always generate message contracts" in the service reference.

© Stack Overflow or respective owner

Related posts about wcf