Youness ARRAF · Jun 22, 2020

CORS ORIGIN ERROR: Consumer an Soap services from xmlHttpRequest


call my web service (%SOAP from caché 2012 v) from XmlHttpRequest client generate  cors policy error, 

Any one help me how i can allow origin in headers requeste.

Thank you.

0 1,703
Discussion (12)3
Log in or sign up to continue

In your class set Parameter HandleCorsRequest = 1

Thank you  YURI MARX GOMES  for your replay,

I added this parametrer but not work,  generate same error  :(

  Do %response.SetHeader("Access-Control-Allow-Origin","*")

not work, 

I can use this in %Soap.WebService ? bellow my request from frontend client


function soapRequest(){
        var soapMessage = '<soapenv:Envelope xmlns:soapenv="" xmlns:abon="http://namespace">'+
                            ' <soapenv:Header/>'+
                                              ' <abon:MESSAGE_TYPE>?</abon:MESSAGE_TYPE>'+
                                               <!--Zero or more repetitions:-->
            function createSoapRequest(method,url){
                var xhr = new XMLHttpRequest();
                if ("withCredentials" in xhr){
                    console.log("with crediential ok");
                }/*else if (typeof XDomainRequest != "undefined"){
                    console.log("xDomaineRequest ok");7
                    console.log("CORS not supportes");
                return xhr;
            var xhr = createSoapRequest("POST","http://vmw-app-dev:57772/csp/vdbcen/API.MSP.AbonContract.cls?wsdl");
            if (!xhr){
                console.log("XHR iccue");
            xhr.onload =  function(){
                var result = xhr.responseText;


Set above instructions in your server cache web service, not in the client.

yes, i added it in my web service.

Parameter HandleCorsRequest = 1;

Thank you agin for your help :)

this solution will be worked on Rest service, 

Can you expose your service as a REST?

Client-side JS is really not suited to working with web services.

@Yuri Marx solution (HandleCorsRequest) would work for REST.

i can't make my service as REST in caché v 2012. do you have an idea how i can do it ?

Thank you for your replay.