function createSoapRequest(method,url){ var xhr = new XMLHttpRequest(); if ("withCredentials" in xhr){ console.log("with crediential ok"); xhr.open(method,url,false); console.log("opend"); }/*else if (typeof XDomainRequest != "undefined"){ console.log("xDomaineRequest ok");7
} else{ console.log("CORS not supportes"); xhr=null; }*/
CORS isnt a problem, is most a solution for security. You can fix CORS with some workarounds but before I recomend you to understand why CORS exists. Here an article explaining more about both the reason and ways to workaround:
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 :(
not work,
I can use this in %Soap.WebService ? bellow my request from frontend client
=============================================================
function soapRequest(){
var soapMessage = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:abon="http://namespace">'+
' <soapenv:Header/>'+
'<soapenv:Body>'+
'<abon:ActivationContrat>'+
'<abon:PUBLISH>'+
'<abon:HEADER>'+
'<abon:SENDER_ID>?</abon:SENDER_ID>'+
'<abon:RECEIVER_ID>?</abon:RECEIVER_ID>'+
'<abon:COMPANY>?</abon:COMPANY>'+
'<abon:COUNTRY>?</abon:COUNTRY>'+
'<abon:DATE>?</abon:DATE>'+
' <abon:MESSAGE_TYPE>?</abon:MESSAGE_TYPE>'+
'</abon:HEADER>'+
'<abon:CONTENT>'+
<!--Zero or more repetitions:-->
'<abon:CONTRAT>'+
'<abon:STORE>?</abon:STORE>'+
'<abon:CASH_DATE>?</abon:CASH_DATE>'+
'<abon:CASH_BOX>?</abon:CASH_BOX>'+
'<abon:CASH_TICKET>?</abon:CASH_TICKET>'+
'<abon:CASH_AMOUNT>?</abon:CASH_AMOUNT>'+
'<abon:EAN>fromtest</abon:EAN>'+
'<abon:ACTIVATION_CODE>3058030416</abon:ACTIVATION_CODE>'+
'</abon:CONTRAT>'+
'</abon:CONTENT>'+
'</abon:PUBLISH>'+
'</abon:ActivationContrat>'+
'</soapenv:Body>'+
'</soapenv:Envelope>';
function createSoapRequest(method,url){
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
console.log("with crediential ok");
xhr.open(method,url,false);
console.log("opend");
}/*else if (typeof XDomainRequest != "undefined"){
console.log("xDomaineRequest ok");7
}
else{
console.log("CORS not supportes");
xhr=null;
}*/
return xhr;
}
var xhr = createSoapRequest("POST","http://vmw-app-dev:57772/csp/vdbcen/API.MSP.AbonContract.cls?wsdl");
if (!xhr){
console.log("XHR iccue");
return;
}
xhr.onload = function(){
var result = xhr.responseText;
console.log(result);
}
xhr.setRequestHeader("Content-Type","text/xml");
xhr.send(soapMessage);
========================================================
Set above instructions in your server cache web service, not in the client.
yes, i added it in my web service.
/// HANDLED CORS POLICY
Parameter HandleCorsRequest = 1;
https://community.intersystems.com/post/enable-cors-csp-zen-applications
https://medium.com/netscape/hacking-it-out-when-cors-wont-let-you-be-gre...
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.
CORS isnt a problem, is most a solution for security. You can fix CORS with some workarounds but before I recomend you to understand why CORS exists. Here an article explaining more about both the reason and ways to workaround:
https://medium.com/@dtkatz/3-ways-to-fix-the-cors-error-and-how-access-control-allow-origin-works-d97d55946d9
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue