Search code examples
.netwcfbinarywebhttpbinding

Is it possible to make a webHttpBinding WCF service to answer binary?


I implemented this contract

[OperationContract]
[WebGet(UriTemplate = "{parameter}", BodyStyle= WebMessageBodyStyle.Bare)]
byte[] Operation(string parameter);

But, when I called the implementation, all I got was something like this:

<base64Binary xmlns="http://schemas.microsoft.com/2003/10/Serialization/">dGVzdA==</base64Binary>

Can't I remove this wrapper and this serialization?


Solution

  • Make it return Stream.

    Stream Operation(string parameter)
    {
       ...
       new MemoryStream(bytes);
    }