0

我正在尝试访问第 3 方 asmx 服务(来自我的 ASP.Net MVC 4 应用程序)。大多数情况下它工作正常,然后突然我开始看到一个错误:

The connection was not closed. The connection's current state is open.

这个问题消失了一段时间,一切正常。然后它再次出现。

我怀疑代理或网络设置,但更改这些设置并没有帮助。我能够毫无问题地“更新服务参考”,这意味着我可以正确访问该服务。

是否有可能在服务端生成此错误并冒泡到我的应用程序?

我可以确定问题是在客户端还是我的?

谢谢

细节:

[System.ServiceModel.FaultException]: {"Server was unable to process request. ---> The connection was not closed. The connection's current state is open."}

Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
  at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
  at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
  at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at MyTDI.ClientWebServices.TDIWS_SalesManagement.WS_SalesManagementModuleSoap.GetAgentCommissions(String Agency_RegNo, DateTime StartDate, DateTime EndDate, Int32 PageNo)
   at MyTDI.ClientWebServices.TDIWS_SalesManagement.WS_SalesManagementModuleSoapClient.GetAgentCommissions(String Agency_RegNo, DateTime StartDate, DateTime EndDate, Int32 PageNo) in d:\Projects\TPLTDI\MyTDIPortal\MyTDI.ClientWebServices\Service References\TDIWS_SalesManagement\Reference.cs:line 111
   at MyTDI.ClientWebServices.Sales.SalesManagementWebService.ListAgentCommissions(String agentId, DateTime startDate, DateTime endDate, Int32 pageNo) in d:\Projects\TPLTDI\MyTDIPortal\MyTDI.ClientWebServices\Sales\SalesManagementWebService.cs:line 31

代码

            DataSet ds = null;
        using( WS_SalesManagementModuleSoapClient client = new WS_SalesManagementModuleSoapClient( ) )
        {
            try
            {
                ds = client.GetAgentCommissions( agentId , startDate , endDate , pageNo );
            }
            catch( Exception ex )
            {
                logger.Error( ex , "" );
                throw new Exception( "Unable to obtain commissions data from server." );
            }
        }
4

1 回答 1

0

错误发生在数据库连接中。确保该SqlConnection对象在您的服务器代码中正确放置(一个好的做法是用using语句包装您的代码)。

于 2013-08-13T07:20:28.573 回答