【发布时间】:2014-12-06 02:13:20
【问题描述】:
在我正在开发的 ASP.Net MVC 4 Web 应用程序中。我有一页基本上通过从 SOAP 服务获取数据来生成报告。
我的代码基本上是这样的
List<CustomThings> serverInfos = ServerInfos;
serverInfos.AsParallel().ForAll(srvInfo =>
{
SoapHttpClientProtocol soapProxy = CreateProxy(srvInfo);
//call make soap calls through the soap client
//store results in the proper places
}
我在这里使用 AsParallel 的原因是因为通过 HTTP 以串行方式执行多个请求需要很长时间。我应该指出这段代码确实有效,虽然偶尔。
是否有可能事情以一种不可预测的方式被处理掉了,而 PLINQ 不是我在这里尝试做的一个好的解决方案?
是否有可能另一个线程问题可能导致导致soap客户端“放弃”的错误?
附加信息
这个特定的 soap 代理正在与 ArcGIS Server 通信。通常,您可以检查服务器日志并查看特定请求何时启动以及请求是否失败。这些日志中没有显示任何内容。
这是我从 AsParallel 代码中获得的内部异常堆栈跟踪的示例。
异常:System.AggregateException:发生一个或多个错误。 ---> System.Net.WebException:底层连接已关闭:预期保持活动状态的连接被 服务器。 ---> System.IO.IOException: 无法从 传输连接:现有连接被强行关闭 远程主机。 ---> System.Net.Sockets.SocketException:现有的 连接被远程主机强行关闭 System.Net.Sockets.Socket.Receive(Byte[] 缓冲区,Int32 偏移量,Int32 大小,SocketFlags socketFlags)在 System.Net.Sockets.NetworkStream.Read(Byte[] 缓冲区,Int32 偏移量, Int32 大小)---内部异常堆栈跟踪结束---在 System.Net.Sockets.NetworkStream.Read(Byte[] 缓冲区,Int32 偏移量, Int32 大小)在 System.Net.PooledStream.Read(Byte[] 缓冲区,Int32 偏移量,Int32 大小)在 System.Net.Connection.SyncRead(HttpWebRequest 请求,布尔值 userRetrievedStream, Boolean probeRead) --- 内部异常结束 堆栈跟踪 --- 在 System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest 请求)在 System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest 请求)在 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(字符串 方法名,对象 [] 参数)在 ESRI.ArcGIS.SOAP.FeatureServerProxy.Query(Int32 LayerOrTableID,字符串 定义Expression、QueryFilter QueryFilter、ServiceDataOptions ServiceDataOptions, String GdbVersion, Double MaximumAllowableOffset) 在 System.Linq.Parallel.SelectQueryOperator
2.SelectQueryOperatorResults.GetElement(Int32 index) at System.Linq.Parallel.QueryResults1.get_Item(Int32 索引) 在 System.Linq.Parallel.PartitionedDataSource1.ListContiguousIndexRangeEnumerator.MoveNext(T& currentElement, Int32& currentKey) at System.Linq.Parallel.PipelineSpoolingTask2.SpoolingWork() 在 System.Linq.Parallel.SpoolingTaskBase.Work() 在 System.Linq.Parallel.QueryTask.BaseWork(对象未使用)在 System.Linq.Parallel.QueryTask.<.cctor>b__0(Object o) at System.Threading.Tasks.Task.InnerInvoke() 在 System.Threading.Tasks.Task.Execute()
【问题讨论】:
标签: c# asp.net-mvc-4 soap-client plinq arcgis-server