In the software industry, many programs require information that you need to fetch from some kind of previously existing business software. In other words, you will probably come across the need to integrate with software from Microsoft, Salesforce, SAP, and other software giants. And, although it might seem intimidating, you can do it! Let me show you how.
Need for Integrating With Microsoft Exchange Server
The most common way of integrating with all types of software is to use their API. The big software companies provide them exactly to make integration possible.
Let’s use Microsoft Exchange as an example. Different operations that you can perform using Exchange’s API in Java are:
- Read e-mails.
- Send e-mails.
- Get information from the appointments on a calendar.
- Insert a new appointment.
- Edit an existing appointment.
- Get information from the task list.
- Insert a new task.
- Edit an existing task.
- Read from a public folder.
- Write into a public folder.
How To Integrate With Microsoft Exchange Server?
The most traditional way to integrate with Exchange from Java used to be the Exchange Web Services (EWS).
- EWS SDK is a SOAP-based API.
- It launched as a part of Microsoft Exchange 2007.
- It is not easy to use, but the real problem is that, back in July 2018, Microsoft declared they would no longer do any feature updates.
Moreover, from Oct 13, 2020, onwards, Microsoft expects everyone using Exchange Web Services for Office 365 integration to switch to Microsoft Graph. Also, on Oct 13, 2020, support for Basic Authentication in Exchange Web Services (EWS) will stop.
Microsoft wants everything moved over to OAuth and Microsoft Graph. Microsoft Graph was launched back in 2015 with Office 365. It delegates calls to several Office 365 Cloud services via a single endpoint. Within Microsoft Graph, you have two options:
- Microsoft Graph data connect.
- Microsoft Graph API.
Microsoft is precise about what you can and cannot do with their API, so it is best to check it out beforehand. You should look into Microsoft Graph data connect if (and only if) you want to work with Big data or need granular consent. If that is not the case, you want the regular API, which is the most common option.
Two versions of Microsoft Graph REST API currently exist – version 1.0 and beta. You can check the beta version, but for any serious development, you should, naturally, keep to the production version 1.0. For that version, make sure you read the documentation and learn the Java SDK.
Ways To Connect To An API
There are two ways in which we can connect to an API:
- Microsoft Graph API.
- Integration Platform.
When you get to the part of actually using the API, you should start by getting:
- Microsoft Account: It can be a company or school account. To get an Application ID.
- Register your Application: Register your application using:
- The Microsoft Application Registration Portal.
- The Azure Active Directory Management Portal.
- Application ID: Once you have registered, an application ID will be created for your app and displayed on your new app’s properties page.
You should use The Azure Active Directory Management Portal for enterprise-class applications.
NOTE: Microsoft Graph changes all the time. Take a look at the changelog to get an idea of the changes that have already happened (since Dec 2015). If you want to work with it, make sure to check which is the current production version of the API.
- You can think of the integration platform as a thin layer you can put between you and the API.
- You write your code for the integration platform, which is *much* simpler.
- Then it is the integration of the platform’s job to translate and “speak” with the API. Unlike the API, you need to pay to use an integration platform, but you usually can start with a free trial.
- Example: Connect Bridge Platform
Connect Bridge Platform: The good thing about this specific integration platform is that it ensures forward and backward compatibility. This means that you build your Java code with Connect Bridge, and then admins can upgrade to a new Exchange version, Microsoft can launch new versions of the API. And you won’t have to worry about any of that.
How Integration Platform Works
- Connect Bridge translates SQL statements into API calls.
- What you put on your code is standard SQL. You write the normal SELECT, UPDATE, INSERT and DELETE statements.
- It works as if you are getting data to and from a relational database using JDBC.
- You can even use stored procedures.
Note: It is all just a layer of abstraction. You are accessing the API, in fact, not Microsoft Exchange’s database.
Problems With Integration Platform
The problem with some integration platforms is that they only work in a specific environment, but in the particular case of Connect Bridge, that is not an issue because you can run it on:
- An Azure-built SaaS platform.
- On-premises/self-hosted (on your own virtual machines or cloud servers).
In this section, we will see how we can use Connect Bridge Management Studio to integrate our Application to the API.
Assuming the Exchange and SharePoint instances already exist, these are the preparation steps you need to follow:
1. Have your target system login information at hand (in this case, Exchange and SharePoint).
2. Install Connect Bridge.
3. Run Connect Bridge Management Studio.
- Add an account for SharePoint (Accounts – Add account). For adding the account, you should select the connector CBSharePointConnector and use the credentials from point 1.
- Add an account for Exchange (Accounts – Add account). For adding the account, you should select the connector MGEXPlugin2010 and use the credentials from point 1.
- For each account, make sure you test the connection so that you know everything is OK with the credentials and parameters you used.
4. Open the New Query option and then the Connection Browser. Find the Exchange connector and expand it until you see the DefaultConnection. Right-click the DefaultConnection and choose the option Get Connection string. You will need it to pass it on to the script, so copy the JDBC connection string.
5. Open the New Query option and then the Connection Browser. Find the SharePoint connector and expand it until you see the DefaultConnection. Right-click the DefaultConnection and choose the option Get Connection string. You will need it to pass it on to the script, so copy the JDBC connection string.
Example: In the below example, we have discussed a java code to integrate Microsoft Exchange and SharePoint.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.