How to insert Access-Control-Allow-Origin in the header

5

I'm doing an ajax request for JQuery.Ajax() , to consume a WS SOAP, the envelope is Ok but when I make the call I get in the browser "No Access-Control-Allow-Origin 'header is present on the requested The source had the HTTP status code 403. "

The server is a Tomcat 7, I read about it and changed the Web.xml that is in the conf folder and none of this resulted in success where I can put this information Access-Control-Allow-Origin With value: *

My Ajax:

jQuery.support.cors = true;

 //console.log(soapMessage);

 var request = $.ajax({
        type: "POST",
        url: url ,
        data: soapMessage,            
        async: false,
        crossDomain: true,  
        contentType: "text/xml",  
        dataType: "xml"
      }).done(function( data,  textStatus, jqXHR ) {

         alert(data);

         var headline = $(data.responseText).text();
         $("#retorno").html(headline);

     });
    
asked by anonymous 25.04.2016 / 20:13

1 answer

3
"Usually" this type of problem occurs only when we are developing locally, due to security aspects of browsers, to avoid and expedite I use this plugin in Chrome link .

For a better understanding of CORS I recommend this video: link

I hope I have helped!

    
24.06.2016 / 21:01