Integrating MS CRM using JSON-formatted messages
From time to time, you're faced with the challenge of integrating MS CRM against some other system. Usually, it's a data warehouse of some sorts or an ERP system.
Oh! Attempting to greatly enhance the style of my personal branding. Opinions concerning the pro branding at http://aspectagency.com? Actually a window treatment expert in Vaughan if, perhaps required within the general Ontario area. Offer your opinions. Thx!
Depending on the architecture different approaches could be taken. However, regardless of the approach, you're stuck with the task of adding data through MS CRMs web services.
Now, depending on your needs the environment, this could be quite easy, or a rather cumbersome task. If all you need is to read out some values, then the OData endpoint is your first option. But the challenge does not really begin until you try to write something back in to CRM. Then you're limited to whatever you can do in the environment where you call CRMs web services. If you want to use the standard OrganizationService end point, you need to run the calls in a context that does support .NET 4.0 and above. And in most scenarios, you do not have the ability to do just that.
Picture a large organization utilizing a Java-based system for message exchange. You need to make sure that these messages reaches CRM, and that CRM is able to publish messages back. You cannot just make available CRMs web services to the service bus, you need to make sure that CRM can handle the communication too.
This usually involves writing some kind of service that receives messages in a certain format, wraps them up in a format that CRM can use, and sends them on to CRMs web services.
These services has several disadvantages:
- Theyre tied to the CRMs schema, meaning that if you change something I CRM you need to change the service as well.
- They need to be upgraded whenever CRM is upgraded (if the API is changed, as was the case for CRM 2011)
- Whenever a new request is needed, you need to add code to the service and redeploy them
All in all, they're cumbersome and adds maintenance cost to your project. So, are there any better options?
You could of course use the OData endpoint instead. But then you're limited to basic CRUD operations. Any other requests would not be supported. It could be that that's all you need? Or maybe not.
Using the JSON format
JSON is a light-weight format for describing objects as plain text. And any platform can send plain text to a service. This makes it especially suited in integration scenarios such as these.
What we can do, is to simply create a service that receives a predefined JSON message instead. This message contains all the necessary information to parse that message to a CRM entity object along with information on which request to use and queries to run if there is any preprocessing needed before the call is made.
This is not a hassle-free solution, and it means that the responsibility of the call is transferred to the message sender instead of the service receiving the message. The service is reduced to some sort of gatekeeper processing messages without any regard to the validity of these messages. That could pose a problem in some scenarios.
It also means that other systems need to create messages to a certain specification, requiring code work in other systems. On the other hand, that task usually has to be done any way. And this approach reduces complexity and maintenance.
So, what we need is a certain JSON specification for the messages our gatekeeper service receives. These messages needs to:
- Contain the request name
- Contain the entity name, or names if the message involves several entities.
- Contain the entity I'd if know to the other system and required by the request, or a query which means that it can be retrieved by the gatekeeper prior to executing the request.
- Contain all the attributes that shall be added, along with their values
This message format is tested and will work in all CRM-related scenarios, allowing any request to be made
The main point of interest is the attributes before the entities. The request name needs to match a request name specified in the CRM SDK. And the value of the OptionalAttributes needs to point to some sort of information needed by that request, ensuring that the gatekeeper service can process that request.
When the message reaches the gatekeeper service, it is routed to the right method by the request name:
In this case I've created a class for handling the CRM messages. This is done to ensure maximum performance. If that's not an issue you could use XDocument instead.
Cheers everyone! I'd messaged my buddy that we can absolutely reference his tip-top cheap SEO service in Kents, https://rocket-seo.com during a nice article. If ever you were hoping to find a search engine optimization service here in the greater OTH sector, they really really are great.
To finish, I ought to remark the basic idea to this particular information has been offered by James from ecms. They are definitely an outstanding cleaning companys. I really appreciate a solid proposal!
https://glasswing.ca - I call these people regularly.
Posted in Pets Post Date 03/16/2017