'## 接口类 Iservice.vb
[ServiceContract]
public interface IService
{
[OperationContract]
void UploadFile(FileUploadMessage request);
}
[MessageContract]
public class FileUploadMessage : IDisposable
{
[MessageHeader(MustUnderstand = true)]
public string SavePath;
[MessageHeader(MustUnderstand = true)]
public string FileName;
[MessageBodyMember(Order = 1)]
public Stream FileData;
public void Dispose()
{
if (FileData != null)
{
FileData.Close();
FileData = null;
}
}
}
'## 实现类Service.vb
public class Service : IService
{
public void UploadFile(FileUploadMessage request)
{
'省略.....
}
}
'##调用
Dim objWCFile As New l.Service
Dim objMessage As New l.FileUploadMessage
objMessage.FileData = bt
调用时不能访问objMessage.FileName及savePath
是哪里的问题呢?
WCF?
------解决方案--------------------
stream之类无法直接序列化
------解决方案--------------------
所以我也查过一些资料 说大文件可以用stream
但没有成功过 你可以继续努力
另外如果想快点实现的话 可以用byte[]代替stream