Cross domain requests for liferay 6.06 web services

I'm already able to access json data from liferay web services using this url and with a proper authentication :

http://login:password@localhost:8080/tunnel-web/secure/json

But I'll need to interrogate this in javascript from another domain name.

I've run into the classic error :

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://my.origin.com/' is therefore not allowed access.

I know I have to allow this origin on the server response header which can be done in jsp like this :

response.setHeader("Access-Control-Allow-Origin", "http://my.origin.com");

The question is, how can I allow this origin for liferay's default webservices ?

edit :

I've tried to add a portal-ext.properties file with :

    axis.servlet.hosts.allowed=
    axis.servlet.https.required=false

    tunnel.servlet.hosts.allowed=
    tunnel.servlet.https.required=false

//empty values are meant to allow any IP...

But it doesn't change anything :(

PS : I'm using liferay 6.06


If you want to alter Tomcat you have to alter liferay web.xml to enable Cors Filter, follow this post:

Access-Control-Allow-Origin: * in tomcat

But to me the best way is having an Apache Web Server (httpd) in front of tomcat/liferay using proxypass module. Apache server runs as reverse proxy for tomcat.

In the proxypass rule you can setup apache to fill the response with some extra headers.

Refer this big post:

How to correctly configure a reverse proxy with Apache, to be used for cross-domain AJAX?

链接地址: http://www.djcxy.com/p/60156.html

上一篇: Liferay Log Utilty

下一篇: 跨域请求生命周期6.06 Web服务