如下一个webservice方法:
/// <summary>
/// 返回图片字节流
/// </summary>
[WebMethod(Description = "Function: use the data to get image byte stream")]
public byte[] GetMapToBytes(List<PointZ> list, DateTime dateTime, MapType type)
{
IMapExport app = new MapExoport();
app.MapType= type;
app.DateTime = dateTime;
app.SetPoints(list);
byte[] re = app.ExportMapStream(); LogUtils.Write(LogFileType.Information, string.Format("方法{0}返回byte[{1}].", "GetMapToBytes", re.Length.ToString()));
return re;
}我把这个webservice发布到了IIS服务器,使用.net客户端测试。客户端调用这个方法的时候,出错:未处理 System.Net.WebException
Message=基础连接已经关闭: 接收时发生错误。
Source=System.Web.Services
StackTrace:
在 System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
在 System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
在 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
在 Test.WebReference.ContourService.GetMapToBytes(PointZ[] list, DateTime dateTime, MapType type) 位置 E:\dn\trunk\com.dn.gisservice\Test\Web References\WebReference\Reference.cs:行号 89
在 Test.Form1.btn_GetMapFrom21Server_Click(Object sender, EventArgs e) 位置 E:\dn\trunk\com.dn.gisservice\Test\Form1.cs:行号 105
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 Test.Program.Main() 位置 E:\dn\trunk\com.dn.gisservice\Test\Program.cs:行号 21
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.IOException
Message=无法从传输连接中读取数据: 远程主机强迫关闭了一个现有的连接。。
Source=System
StackTrace:
在 System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
在 System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
在 System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
InnerException: System.Net.Sockets.SocketException
Message=远程主机强迫关闭了一个现有的连接。
Source=System
ErrorCode=10054
NativeErrorCode=10054
StackTrace:
在 System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
在 System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException: 请问这个错误是怎么回事?急。
从后台记录的日志来看, LogUtils.Write(LogFileType.Information, string.Format("方法{0}返回byte[{1}].", "GetMapToBytes", re.Length.ToString()));
这句已经执行了,为什么返回一个字节数据会失败呢??
/// <summary>
/// 返回图片字节流
/// </summary>
[WebMethod(Description = "Function: use the data to get image byte stream")]
public byte[] GetMapToBytes(List<PointZ> list, DateTime dateTime, MapType type)
{
IMapExport app = new MapExoport();
app.MapType= type;
app.DateTime = dateTime;
app.SetPoints(list);
byte[] re = app.ExportMapStream(); LogUtils.Write(LogFileType.Information, string.Format("方法{0}返回byte[{1}].", "GetMapToBytes", re.Length.ToString()));
return re;
}我把这个webservice发布到了IIS服务器,使用.net客户端测试。客户端调用这个方法的时候,出错:未处理 System.Net.WebException
Message=基础连接已经关闭: 接收时发生错误。
Source=System.Web.Services
StackTrace:
在 System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
在 System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
在 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
在 Test.WebReference.ContourService.GetMapToBytes(PointZ[] list, DateTime dateTime, MapType type) 位置 E:\dn\trunk\com.dn.gisservice\Test\Web References\WebReference\Reference.cs:行号 89
在 Test.Form1.btn_GetMapFrom21Server_Click(Object sender, EventArgs e) 位置 E:\dn\trunk\com.dn.gisservice\Test\Form1.cs:行号 105
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 Test.Program.Main() 位置 E:\dn\trunk\com.dn.gisservice\Test\Program.cs:行号 21
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.IOException
Message=无法从传输连接中读取数据: 远程主机强迫关闭了一个现有的连接。。
Source=System
StackTrace:
在 System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
在 System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
在 System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
InnerException: System.Net.Sockets.SocketException
Message=远程主机强迫关闭了一个现有的连接。
Source=System
ErrorCode=10054
NativeErrorCode=10054
StackTrace:
在 System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
在 System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException: 请问这个错误是怎么回事?急。
从后台记录的日志来看, LogUtils.Write(LogFileType.Information, string.Format("方法{0}返回byte[{1}].", "GetMapToBytes", re.Length.ToString()));
这句已经执行了,为什么返回一个字节数据会失败呢??
解决方案 »
- Asp.Net如何实现多线程上传大文件,最好有控件和使用教程
- 如何反射类库的类文件中的变量并赋值
- entity framework 更新问题
- ASP.NET EXCEL导出的问题,高手帮一下忙.
- GridView怎么邦定HyperLink控件的Enabled属性?
- 怎麼樣瓤textarea的滾動條一直停留在最底下啊.如果不去拉的話.
- OA开发练习,有兴趣的朋友请进
- 不上传文件的时候,单击"提交"的问题.
- 代码中操作datagrid中的editcolumn显示问题
- 一个数据库查询的问题
- 关于部署的一个简单问题。
- 各个节在每个配置文件中只能出现一次。有关异常的信息 请参阅帮助主题 location 。
你可以考虑 先测试下 是不是文件没有进入byte中。 或者是不完成的文件进去了建议是本机测试一下。 然后放到服务器上去测一下。还有一种可能就是 没有那图片。 因为你的这段代码也没有catch块来获取错误信息。
过了几天时间,现在又这样了。
查看IIS日志,发现里面记录的实际发送的字节数和应该发送的字节数不一样,相差很多,所以应该是IIS在发送数据的时候中断了连接,但是不知道是什么原因导致了连接的中断?大侠们帮帮忙,分析一下,是IIS BUG,内存泄露?还是其他的什么原因,现在我不知道怎么着手去分析这个问题了。