My goal is to connect to Symfony throughout a WSSE protocole. I have a code which works perfectly when I try to connect to Symfony locally but not when I try to connect to the same Symfony on a distant server. (All the code are the same, the only parameters which change is the APILINK, I also set the .htaccess to allow all headers, requests and origins)
Here is the code (javascript)
SimpleWSSEAuth.setup = function(username, password, salt, options) {
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
jqXHR.setRequestHeader('Authorization', 'Authorization profile="UsernameToken"');
jqXHR.setRequestHeader('X-WSSE', SimpleWSSEAuth.BuildXWSSEHeader(username, password, salt));
});
};
SimpleUserAPI.WSSEAuthentification = function(password, data, success, error) {
SimpleWSSEAuth.setup(data.username, password, data.salt);
$.ajax({type: 'GET', dataType:"json", url: APILINK + "public/user", crossDomain: true}).done(success).fail(error);
};
As you can see I call the SimpleWSSEAuth.setup before my ajax request.
Here is my request when APILINK is local:
Here is my request when APILINK is distant:
As you can see the elements 'Authorization' and 'X-WSSE' are presents in the first request but not in the second.
How could I change my request to add those 2 elements with a distant server ? Is it a cross-domain problem ? I tried to find solutions online but I didn't find anything which works actually.
by looking at your screenshot for distant api link, you are getting "405 method not allowed error" with your ajax call. You need to set dataType to JSONP instead of JSON and also set crossDomain true in your ajax method
$.ajax({type: 'GET', dataType:"jsonp", crossDomain: true, ...}}