Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Connect to Dynamics CRM 2015 On-Premise Using CRMServiceClient from external application

Posted on by Microsoft Employee

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

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Connect to Dynamics CRM 2015 On-Premise Using CRMServiceClient from external application

    I posted in this hopes that the issue was caused by a simple connection issue on my part to the CRM.

    If this isn't the case, I certainly understand that it might be difficult to trouble shoot without access to the javascript or web service code.

    To answer my overall higher arching question of how to connect to the CRM,

    I found the following link helpful.

    community.dynamics.com/.../252864

    I'll just have to continue looking into the issue one step at a time from here.

    Thanks everyone for looking.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans