I have been working on JSONP implementation on webMethods 9.5 and im not able to set and use authorization header in my AJAX call. In the browser it throws a pop up asking for the Authorization. I have developed the project on MWS as dynamic web project.
It was very tricky to implement JSONP and make it work. Here is what i did.
Created a normal flow service which give JSON string.
Created another flow service that pads the data with function body i.e JSON with padding equals JSONP
Ex: callback(‘+json data from the flow service+’);
Now to implement CORS i had to set the Access-Control-Allow-Origin header to the host name of MWS server which is installed another server and set the response content type as “application/javascript”.
Now the problem is if i try to connect the http service like mentioned below, I get a pop up to provide the user id and password. I have set the setRequestHeader explicitly to make sure it is used.
You are right it is JQuery in my Javascript function. Im using this in my page header
I have tried the latest JQuery code also.
The Username and password attribute is available in JQuery but here is the problem,If i use these attribute the browser prompts me to provide the user id and password.
This user id and password should be ecoded to base64 and then sent in the Authorization header to IS. It looks something like this : “Authorization”:“Basic QWRtaW5pc3RyYXRvcjptYW5hZ2U=”(Administrator:manage).
Hence i tried to set this header explicitly using the beforeSend attribute of JQuery.
$.ajax({
type: ‘GET’,
beforeSend: function (xhr) {
xhr.setRequestHeader (“Authorization”, “Basic " + btoa(“kikad”+”:“+“condra06a”));
},
url: “http://ptseelm-lx4432.ikeadt.com:5555/invoke/test1/getData”,
dataType: “jsonp”,
jsonpCallback:“callback”}).done(function(results){ $(‘#para’).html(”
“+results.name+”
");
});
I also tried the one you mentioned too. but no luck in sending the authorization header.
I tried to change the ACL of my service in IS to annonymous and then access it no matter what the user id and password i mention it will run.
I think it is something to do with the ACL i need to set the right ACL to my IS service that allows to send this Authorization header or i have to setup https that seems like the best way to do it !