与WCF流传输的限制 [英] Streamed transfer restrictions with WCF
问题描述
据在MSDN中的以下指南,使用流式传输的任何操作只能有一个输入/输出参数
According to the following guide at MSDN, any operations that use streamed transfers can only have one input/output parameter.
链接: http://msdn.microsoft.com/en-us/library/ms731913.aspx (见标题为关于转让流限制)
Link: http://msdn.microsoft.com/en-us/library/ms731913.aspx (see heading "Restrictions on Streamed Transfers")
我使用WCF服务,让客户/消费者将文件上传到它流传输。上传本身工作正常,但我需要传递两个更多的输入参数与Stream对象一起的一种方式:字符串的文件名和INT用户ID
I'm using streamed transfers for a WCF service that lets clients/consumers upload files to it. The upload itself works fine, but I need a way of passing two more input parameters along with the Stream object: 'string filename' and 'int userid'.
将如何我去这样做。
推荐答案
There's东西叫头,你可以在你的datacontract使用:
There´s something called headers that you can use in your datacontract:
接口的实例:
[ServiceContract]
public interface IFile
{
[OperationContract]
Stream DownloadFile(int fileid);
[OperationContract]
bool UploadFile(FileUploadMessage request);
}
在一个单独的文件将这个:
Put this in a separate file:
[MessageContract]
public class FileUploadMessage
{
[MessageHeader(MustUnderstand = true)]
public int MyInt {get;set;
[MessageHeader(MustUnderstand = true)]
public string MyString {get;set;
[MessageBodyMember(Order = 1)]
public System.IO.Stream FileByteStream {get;set;}
}
这篇关于与WCF流传输的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!