Hello all,
I hopefully have a pretty quick and easy question regarding the connection of external apps to Dynamics CRM 2015 on-premise.
Long story short, I have the following Scenario...
1. Ribbon button on an form is pressed
2. An ajax call is performed via JavaScript to a WCF service.
3. The WCF service performs its requested operations then connects to the CRM using CrmServiceClient.
4. The ajax gets the response that the WCF service is done running and it gives the response back to the user.
This feature is used over 50 times in a day, every single day.
Maybe once every 4 or 5 days the WCF service will throw an exception on one of the statements that performs an update or create operation against the CRM.
The error is generally something along the lines of 'An error occured while processing this request.'
When the error occurs, the user will press the exact same button on the same form again, and it will go through and create the additional record through the WCF service without any issues....
Since the same exact record will work the second time around, and it only happens once every couple hundred requests... my only thought is that it might be related to how I am connecting to the CRM?
This is how I am initializing my connection to the CRM:
CrmServiceClient service = new CrmServiceClient(WebConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
if(service.IsReady)
{
// Perform my business logic.
}
Basically, my question is, is the above code the best way to connect to an on-premise version of CRM or is there something else I should be doing?
Looking at this post on MSDN - https://msdn.microsoft.com/en-us/library/jj602970.aspx - I see this:
CrmServiceClient service = new CrmServiceClient(WebConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
IOrganizationService orgService = (IOrganizationService)service.OrganizationWebProxyClient != null ? (IOrganizationService)service.OrganizationWebProxyClient : (IOrganizationService)service.OrganizationServiceProxy;
Is the IOrganizationService statement needed? If so, why and when should I use it? Do you think this would even make a difference in the issue I am experiencing?
Thank you so much!
*This post is locked for comments