简体   繁体   English

如何解决此错误“ System.ServiceModel.FaultException”

[英]How can i solve this error “System.ServiceModel.FaultException”

Everytime I stop the program and rerun again the error message pop 每次我停止程序并再次运行时,都会弹出错误消息

PX.Data.PXException: API Login Limit at PX.Api.ContractBased.Soap.WebApiSoapController.Post(ISoapSystemContract systemContract, XmlReader requestReader, String serviceNamespace, String internalNamespace, MethodInfo method, Func 1 serviceFactory, IEdmModel edmModel) at PX.Api.ContractBased.Soap.WebApiSoapController.<Login>d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3 1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext() --- End of stack trace fr PX.Data.PXException:PX.Api.ContractBased.Soap.WebApiSoapController.Post(ISoapSystemContract systemContract,XmlReader requestReader,字符串serviceNamespace,字符串internalNamespace,MethodInfo方法,Func 1 serviceFactory, IEdmModel edmModel) at PX.Api.ContractBased.Soap.WebApiSoapController.<Login>d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3 API登录限制1 serviceFactory, IEdmModel edmModel) at PX.Api.ContractBased.Soap.WebApiSoapController.<Login>d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3 1.MoveNext()---从上一个引发异常的位置开始的堆栈跟踪---位于System.Runtime.ExceptionServices.ExceptionDispatchInfo。 System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()处System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)处的Throw()---堆栈结束跟踪fr om previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ExceptionFilterResult.d__0.MoveNext() 在发生异常的先前位置---在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task任务)在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext ()---从上一个引发异常的位置开始的堆栈跟踪---位于System.Web的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task任务)的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()处。 Http.Controllers.ExceptionFilterResult.d__0.MoveNext()

this is my code on log in 这是我登录时的代码

...
using (DefaultSoapClient soapClient = new DefaultSoapClient())
{
       //Log in to Acumatica ERP        
       soapClient.Login
       (
            Properties.Settings.Default.UserName,
            Properties.Settings.Default.Password,
            Properties.Settings.Default.CompanyName,
            Properties.Settings.Default.Branch,
            null
       );
 ...
      try
      {
           ...
           soapClient.Logout();
      }
      catch (Exception e)
      {
           ...
           soapClient.Logout();
      }
      finally
      {
           ...
      }

what's wrong with my code and how do I fix it? 我的代码有什么问题以及如何解决?

Unlicensed demo versions have a limited amount of API connection session available. 未经许可的演示版本具有数量有限的可用API连接会话。

You have to make sure Logout is always called after Login otherwise you'll run out of available connection sessions. 您必须确保在登录后始终调用注销,否则您将耗尽可用的连接会话。 For unlicensed version you should aim for a maximum of 1 connection at any time and make sure the application can't be stopped without executing the API connection session logout. 对于非许可版本,您应该随时争取最多1个连接,并确保不执行API连接会话注销就无法停止应用程序。

Here's the stategy I would use to ensure that: 这是我将用来确保的策略:

  • Use only single threaded code to interact with the API because you want to avoid multiple concurrent connections when using unlicensed version. 仅使用单线程代码与API交互,因为在使用未经许可的版本时,您要避免多个并发连接。

  • Wrap all code interacting with the API in exception block that will always call logout. 包装所有的代码在异常块的API,它总是会调用注销交互。 It doesn't hurt to be paranoid here, you can event put the login code in the try block because if login fails there's no harm in trying to logout. 在这里被偏执并没有什么坏处,您可以将登录代码放入try块中,因为如果登录失败,则尝试注销没有任何危害。

  • Try to make your session short and to the point, don't login pre-emptively or keep the connection opened for longer than required. 尽量使会话简短,切勿随意抢先登录,或保持连接打开时间长于所需时间。 Having sessions hanging around for too long increases the chances of losing the connection before you can issue the logout command or simply forgetting to logout. 将会话挂起的时间过长会增加失去连接的机会,然后您才可以发出注销命令或只是忘记注销。

  • Register an application wide OnClose event handler to Logout of the session when the user soft closes the application. 用户软关闭应用程序时,将应用程序范围的OnClose事件处理程序注册到会话的注销。 If the user hard closes the application (ex: by killing it with task manager) you can't execute logout so you'll have to wait for the session to expire or restart IIS to avoid API connection limit exceeded errors. 如果用户很难关闭应用程序(例如:通过任务管理器杀死它),你不能执行注销,所以你必须等待会话过期或重新启动IIS,以避免API连接限制的错误。

  • Log each connection login/logout attempts to disk (whether successful or not) to make sure it always calls logout for each login. 将每个连接登录/注销尝试记录到磁盘(无论成功与否),以确保它始终为每个登录调用注销。 When login is executed create a unique id for that connection and log it, when logout is executed log it with the same unique id. 执行登录后,为该连接创建一个唯一的ID并将其记录下来;执行注销时,使用相同的唯一ID对其进行记录。 If you get the API limit error again you'll have log data to confirm whether or not you have successfully logout of all opened sessions. 如果再次遇到API限制错误,您将获得日志数据以确认是否已成功注销所有打开的会话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.ServiceModel.FaultException - 如何解决这个问题 - System.ServiceModel.FaultException - how to solve this 如何克服System.ServiceModel.FaultException - how to overcome System.ServiceModel.FaultException System.dll中的System.ServiceModel.FaultException - System.ServiceModel.FaultException in System.dll System.ServiceModel.dll中的“ System.ServiceModel.FaultException”:过程不存在 - 'System.ServiceModel.FaultException' in System.ServiceModel.dll: Procedure not present 自承载WCF和System.ServiceModel.FaultException - Self-Hosting WCF and System.ServiceModel.FaultException System.ServiceModel.FaultException - System.ServiceModel.FaultException<DefaultFaultContract not catching some exceptions WCF单元测试结果在System.ServiceModel.FaultException中 - WCF Unit Testing Results in a System.ServiceModel.FaultException 在Dynamics CRM中将RetrieveMultiple与FetchXML一起使用时,出现“ System.ServiceModel.FaultException`1” - 'System.ServiceModel.FaultException`1' when using RetrieveMultiple with FetchXML in Dynamics CRM XAMARIN.ANDROID 应用出现 System.ServiceModel.FaultException - XAMARIN ANDROID app got System.ServiceModel.FaultException Synergy dbr.exe在xcall期间获取System.ServiceModel.FaultException - Synergy dbr.exe getting System.ServiceModel.FaultException during xcall
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM