How to enable CORS on a Websphere Application Server (WAS 8.5)

In case you have a little DNG Javascript embedded in a Webpage and you want to  access RTC (running in a different domain) , then you need CORS. The question is “how to enable it with WAS? It seems that WAS itself could not configured but the WAS Apps (i.e. ccm) could be. This means you have to change your web.xml files.

Another possibilty is the IHS Server running in front of a WAS Server. The IHS is often used as reverse Proxy. Until now I have to investigate that.

Back to WAS…I found the information at stackoverflow. BTW, Tomcat is a little bit easier to config…details are here.

Before we go to WAS config let me mentioned that you have to enable CORS inside your web app with:

$.ajaxSetup({
       crossDomain: true,
        xhrFields: {
        withCredentials: true
    }
});

Go to the installation directory of WAS and find the ccm (alias RTC)  location.

In my environment it is at: C:\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\clmserverNode01Cell\ccm_war.ear\ccm.war\WEB-INF Include the following lines inside web.xml


<filter-name>CORS</filter-name>

<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>

</filter> <filter-mapping>

<filter-name>CORS</filter-name>

<url-pattern>/*</url-pattern> </filter-mapping>

Add the jar files to your

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\clmserverNode01Cell\ccm_war.ear\ccm.war\WEB-INF\lib folder

Restart “ccm” from the WAS console Bildschirmfoto 2015-01-07 um 18.21.28 Test it with http://test-cors.org (maybe you need to login to https://clmserver:9443/ccm before, because of the problems with the “self signed certificates” from ccm) and use https://clmserver:9443/ccm/rootservices

Bildschirmfoto 2015-01-07 um 18.24.25

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: