tags:

views:

39

answers:

2

Hi all,

I wondering if in the same endpoint, which has been set to streamed transport mode, is it required to have all operation contracts in this service to have a stream in the parameter or as the return type for this service to work?

In short: Can streamed enabled endpoint contain operation contracts that do not have stream as a parameter or as a return type?

A: 

Hi Tri Q,

Yes, you can keep the same contract even if you use an stream endpoint, it doesn't matter if it contains the stream as a return type or parameter.

For it to work you need to change some of the members of the contract to the headers.

[MessageContract]
public class MyContract
{
    [MessageHeader]
    public string FileName { get; set; }

    [MessageBodyMember]
    public Stream Content { get; set; }
}
Mharlin
A: 

Check the MSDN docs on Streaming Message Transfer:

Restrictions on Streamed Transfers

Using the streamed transfer mode causes the run time to enforce additional restrictions.

Operations that occur across a streamed transport can have a contract with at most one input or output parameter. That parameter corresponds to the entire body of the message and must be a Message, a derived type of Stream, or an IXmlSerializable implementation. Having a return value for an operation is equivalent to having an output parameter.

So if you have a service contract that will be exposed over an endpoint with streaming enabled, all operations on that contract must be using Message, or Stream as their single parameter.

marc_s