I've developed a couple of OData services via SEGW and Net Weaver Gateway, and everything is working fine. However, when I write JS to consume them, I'm getting a Cross Origin Policy.
Within my 'DPC_EXT' class in the redefined 'GET_ENTITYSET' method, I've tried adding the code:
data: ls_header TYPE ihttpnvp.
ls_header-name = 'Access-Control-Allow-Origin' .
ls_header-value = '*'.
/iwbep/if_mgw_conv_srv_runtime~set_header( ls_header ).
-----------------------------------
Here is my JS call:
$.ajax({
url: 'http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/',
dataType: 'XML',
success: function (result) {
alert(result)
}});
-----------------------------------
I'm still getting this error:
XMLHttpRequest cannot load http://XXXXXXXXXXXXXXXXX. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8082' is therefore not allowed access.
Any help is appreciated!