[ServiceContract, XmlSerializerFormat]
public interface IReplicationWebService
{
[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "agents/{sourceName}/epoch/{guid}/{number}/{type}")]
ReplayResult PutEpochFile(string sourceName, string guid, string number, string type, Stream stream);
}
在执行本合同时,我们从以下来源读取数据
stream
public ReplayResult PutEpochFile(string sourceName, string guid, string number, string type, Stream inStream)
{
//Stuff snipped
try
{
//Read from the stream and write to the file
}
catch (IOException ioe)
{
//IOException may mean no disk space
try
{
inStream.Close();
}
// if instream caused the IOException, close may throw
catch
{
}
_logger.Debug(ioe.ToString());
throw new FaultException<IOException>(ioe, new FaultReason(ioe.Message), new FaultCode("IO"));
}
}
为了测试这一点,我将向没有足够空间的服务器发送一个100GB的文件。正如预期的那样,这会抛出一个异常,但调用
inStream.Close()
Close()
System.ServiceModel.Channels.DrainOnCloseStream.Close()
Byte[]
Close
在这条小溪上。如果是这样的话,我想解释一下原因。但更重要的是,如果有人能向我解释原因,我将不胜感激