添加文件名和长度参数WCF流时Transfermode =流 [英] Add filename and length parameter to WCF stream when Transfermode = Stream
本文介绍了添加文件名和长度参数WCF流时Transfermode =流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在此相反,以所有的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;
}
这篇关于添加文件名和长度参数WCF流时Transfermode =流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文