Web messaging comet cross-domain bayeux webmsgServlet

361 views Asked by At

I'm writing a mobile application using phonegap that subscribes to a SIBus jms Topic.

First I was able to run a demo after configuration but I'm not able to run It from a different domain because the application must be runnig on an external domain from the server.

I had many problems with cross domain ajax call to webservices the solution was to change the header to header("Access-Control-Allow-Origin", "*"); I'm worndering how to fix this to change the header to the incoming requests

dojo.require("dojox.cometd");
   dojo.addOnLoad(function(){
      dojox.cometd.init("http://localhost:9080/ClientWeb/webmsgServlet");
      dojox.cometd.subscribe("/T.Frs", window, "display");
     }
   );
   function display(msg) {
   console.log(msg);
       alert("Message " + msg.data.test);
   }
1

There are 1 answers

1
sbordet On

Have a look at Jetty's CrossOriginFilter, it is a portable filter you can run in any servlet container that implements the CORS specification, allowing you to access cross origin resources seamlessly.

CometD ships this filter by default in the demo, so you can have a look there to see how is configured, or look at the CometD reference, section 5.4.1.3.