Reputation: 29
We currently have a javascript client successfully accessing a web service on another domain using something similar to the following code:
var postXml = "" +
"<aaa:getSomething>" +
"<param1>" + obj.param1 + "</param1>" +
"<param2>" + obj.param2 + "</param2>" +
"</aaa:getSomething>";
var data = this.createEnvelope(postXml);
var request = Ext.Ajax.request({
url : this.webServiceUrl,
method : "POST",
callback : this.onGetSomething,
obj : obj,
scope : this,
headers : {
SOAPAction: "urn:onGetSomething"
},
xmlData : data
});
We are being required to add WS-ReliableMessaging to our web service. Is there a way to modify our javascript client to connect to the new WS-ReliableMessaging-enabled service? I'm not very Javascript-savvy, but from my research so far I suspect the only way might be to make the Ajax request to a local server-side proxy JSP that makes the call from Java, is this the case?
Upvotes: 0
Views: 581
Reputation: 4760
You should JSON-P for cross-domain access, if you check the Ajax documentation here: http://docs.sencha.com/extjs/5.1/5.1.0-apidocs/#!/api/Ext.data.proxy.Ajax, the limitations section says:
"AjaxProxy cannot be used to retrieve data from other domains. If your application is running on http://domainA.com it cannot load data from http://domainB.com because browsers have a built-in security policy that prohibits domains talking to each other via AJAX.
If you need to read data from another domain and can't set up a proxy server (some software that runs on your own domain's web server and transparently forwards requests to http://domainB.com, making it look like they actually came from http://domainA.com), you can use Ext.data.proxy.JsonP and a technique known as JSON-P (JSON with Padding), which can help you get around the problem so long as the server on http://domainB.com is set up to support JSON-P responses. See JsonPProxy's introduction docs for more details."
Upvotes: 0