2

I have a Java REST webservice deployed on tomcat (http://localhost:8080/myrestfulapp/aservice/).

In my qooxdoo app, I try to send a POST request using qx.io.remote.Request. I built the application and deployed it on an apache HTTP server (named http://myserver.org). When I try to send the request, I get this error in javascript console of my web browser (Chrome on linux): Origin http//myserver.org is not allowed by Access-Control-Allow-Origin

I added crossdomain.xml in tomcat's ROOT webapp, in /var/www and in my http server's root directory. I enabled apache headers (a2enmod headers) and I added Access-Control-Allow-Origin "*" in my server's configuration file.

here is my qooxdoo function sending the request:

envoyer : function(id, nom, prenom, poste) 
{
  var url = "http://localhost:8080/helloworld/enregistrer";
  var donnees = "{ \"id\":" + id + ", \"nom\":\"" + nom + "\", \"prenom\":\"" + prenom + "\", \"poste\":\""+poste +"\" }";
  alert(donnees);
  var req = new qx.io.remote.Request(url, "POST", "application/json");
  req.setData(donnees);

  req.addListener("completed", function(e) {
            alert(e.getContent());
  });
  req.send();
}

and here is the myserver.org configuration file: ServerAdmin webmaster@localhost serverName myserver.org

DocumentRoot /home/jihedamine/HttpServer
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
<Directory /home/jihedamine/HttpServer/>
    Header set Access-Control-Allow-Origin "*"
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

So how could I enable sending cross origin http requests from a qooxdoo app to a java backend deployed on tomcat ?

Jihed Amine
  • 2,198
  • 19
  • 32
  • 1
    Cross domain request control is a browser feature so i do not think you can do anything in the server side regarding this. jsonp format may help you regarding this – Arun P Johny Jan 04 '11 at 03:24
  • 1
    You do have some server side options for cross-domain support in modern browsers. Check out https://developer.mozilla.org/En/HTTP_Access_Control – cjimti Jan 11 '11 at 23:19

1 Answers1

1

When you try to access a other domain with qooxdoo you have to set the property "crossDomain" from your "qx.io.remote.Request" instance to "true":

req.setCrossDomain(true);

For more details have a look at the API doc: http://demo.qooxdoo.org/current/apiviewer/#qx.io.remote