Company focused web service call causes "There is no Active Session within the filter" error

Dear All,

I am working on integration with NAV via OData/SOAP. My .NET app using autogenerated clients. Everything is ok with system services (http://myNav.com:7047/MyNavServer/WS/SystemService or http://myNav.com:7048/MyNavServer/OData requesting “Company” entity), but when I am trying to call something company related (e.g. http://myNav.com:7048/MyNavServer/OData/Company(‘MyComp’)) several times, only the first call is successful, second throws an exception

System.Data.Services.Client.DataServiceQueryException : An error occurred while processing this request.
----> System.Data.Services.Client.DataServiceClientException : <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="">schemas.microsoft.com/…/metadata"><m:code /><m:message xml:lang=“en-US”>There is no Active Session within the filter.

Filters: Server Instance ID: 1029, Session ID: 434</m:message></m:error>
at System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents)
at System.Data.Services.Client.DataServiceQuery1.Execute() at System.Data.Services.Client.DataServiceQuery1.GetEnumerator()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.Enumerable.ToArray(IEnumerable`1 source)
at CRM.DevX.Tests.Integration.Nav.Odata.CompanyInformationClientTests.CompanyInformationService_SingleRequest(String companyName) in CompanyInformationClientTests.cs: line 16
at CRM.DevX.Tests.Integration.Nav.Odata.CompanyInformationClientTests.CompanyInformationService_MultipleSequentalRequests_UsingPersonalClients(String companyName) in CompanyInformationClientTests.cs: line 28
–DataServiceClientException
at System.Data.Services.Client.QueryResult.ExecuteQuery()
at System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents)

Several requests made sequentially are possible only if there is a 15-20 sec delay between them. I’ve tried using same client instance for all the requests and separate for every request, same exception.
The same situation with SOAP services.
What I am doing in a wrong way. Please help.

I would try to not reuse the same connection but create a new one. This should help you.

I’ve tried. I’ve used separate client instance for every request, same error.

solved OnAfterGetRecord trigger of Company Information page runs following code when System Indicator is “Company + Database” : ActiveSession.SETRANGE("Session ID",SESSIONID); ActiveSession.FINDFIRST; The code causes the error. At Company Information page edit form I’ve changed System Indicator field value from “Company + Database” to “Company”.

solved

OnAfterGetRecord trigger of Company Information page runs following code when System Indicator is “Company + Database” :
ActiveSession.SETRANGE(“Session ID”,SESSIONID);
ActiveSession.FINDFIRST;

The code causes the error.

At Company Information page edit form I’ve changed System Indicator field value from “Company + Database” to “Company”.