在此相反,以所有的SO职位,谈论这个话题,我不感兴趣,在 [MessageContract]
,因为这是不允许的包装流对象当流模式(据我所知)。
In contrast to all the SO posts that talk about this topic, I'm not interested in wrapping a stream object in a [MessageContract]
, since that is not permitted when in streaming mode (afaik).
当我在流模式,我怎么返回给客户端的一些元数据,如长度和文件名?我可以添加一个WCF / SOAP头?我将如何做到这一点?
When I'm in streaming mode, how do I return to the client some metadata, such as length and filename? Can I add a WCF/SOAP header? How would I do this?
我期待到扩展文件流类,并添加 [的MessageHeader]
属性,但我无法得到这个工作。
I am looking into extending the filestream class and add a [MessageHeader]
attribute, but I'm unable to get this to work.
下面是我们如何做到这一点
here is how we do it
[MessageContract]
public class StreamMessage
{
[MessageHeader(MustUnderstand = true)]
public long Length { get; set; }
[MessageHeader(MustUnderstand = true)]
public int ServerVersion { get; set; }
[MessageHeader(MustUnderstand = true)]
public byte[] Cerificate { get; set; }
[MessageBodyMember(Order = 1)]
public Stream Stream;
}