sabato 14 novembre 2015

How to call a Rest Service on ICS (Integration Cloud Service) from JCS (Java Cloud Service)

This is a sample of URL of a service created on ICS:

It is a service on ICS that makes a call to RightNow. (we are requesting the INCIDENT with ID = 35)
This service requires HTTPS and Basic Authentication.

To be able to call a Rest Service on ICS from JCS, you can create on JCS, for example, a simple jsp page in which you can use JQuery.

But in this scenario you will have CORS problems.

To solve in a simple way CORS problems you can use this Proxy Servlet (CORS) : this is a war archive with .class & .java file.

If you whant you can deploy the ProxyServlet in the same WLS where is starting the request to ICS or in a different WLS.

This proxy is useful also on premise.
If you deploy it in your local computer you will have this exception during a call: Hostname verification failed:, hostname=icsemeapmtrial-icsemeapmt

As workaround, you can solve it on WLS  turning off hostname verification.
In the admin console: Servers -> server name -> Configuration SSL tab -> Advanced -> Change Hostname Verification dropdown to None

The only thing that you need to do is to deploy and activate it on WLS and if you need an example on how to call it see the following JSP: IcsRightNow.jsp ( for this sample remember to put jquery lib in the same directory of the jsp)

In the following image you can see the structure of the project that I have created on a previous tutorial, and you can see where to put JQuery lib and jsp file:

To deploy the Proxy Servlet (CORS) on WLS on JCS is very simple, once you have downloaded it on your computer:

Open your Weblogic Console on JCS, click on "Lock & Edit", then select "Deployments" and then click on "Install" button, now you can upload your war on JCS:

Remember to choose a correct Target (all the cluster maybe is the best choice) for the deployment, remember at the end of the operations to click on "Activate Changes" and then to "Start" the application:

1 commento: