sapui5 OData.V4.oDataModel with Teiid 11.2 / Wildfly










1















I am trying to use SAPUI5 in a SPA to display data from a TEIID/Wildfly ODataV4 service. When SAPUI5 ODATA V4 data model is bound to the service, I run into several errors. I thereby connect via proxy (grunt-connect-proxy2) to the odata service. Basic Auth works. The metadata file above the marked service folder in the attached image (screenshot1) is the actual metadata file of the service which, as you can see, is loaded correctly. So no CORS issue or authorization issue.



Screenshot1



Screenshot1



The issue seems to be related to an CSRF Token request as far as I understand. Seems that Teiid/Wildfly is not answering the CSRF Token fetch request. Is there a way to configure Wildfly to answer the request or alternatively a way to disable CSRF requests for the odata V4 model? I have seen such an option in the constructor of the odata V2 model. How could a working configuration look like?



The following is a screenshot from the browser log:



I observed a further issue, from which I do not know if it is related to the previous one (there is also a X-CSRF-Token: Fetch involved), or if a have something more missing somewhere. The second issue happens when I use an aggregation binding to bind a odata collection to a sapui5 list. The response looks like




Request URL: http://localhost:9001/odata4/svc/my_nutri_diary/$batch
Request Method: POST Status Code: 406 Not Acceptable Remote Address:
[::1]:9001 Referrer Policy: no-referrer-when-downgrade Response
Headersview source access-control-allow-credentials: true
access-control-allow-origin: http://localhost:9001 cache-control:
no-cache, no-store, must-revalidate connection: close
content-encoding: gzip content-length: 125 content-type:
application/json;odata.metadata=minimal date: Mon, 12 Nov 2018
20:04:30 GMT expires: 0 odata-version: 4.0 pragma: no-cache server:
WildFly/11 x-powered-by: Undertow/1 Request Headersview source Accept:
multipart/mixed Accept-Encoding: gzip, deflate, br Accept-Language: de
Authorization: Basic SU1TVXNlcjpJTVM0Zm9ydW0l Connection: keep-alive
Content-Length: 329 Content-Type: multipart/mixed;
boundary=batch_id-1542053070786-11 Cookie: sidebar_collapsed=false;
cycle_analytics_help_dismissed=1;
__utmz=111872281.1539128843.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=111872281.767670437.1539128843.1541866362.1541870562.42 DNT: 1 Host: localhost:9001 MIME-Version: 1.0 OData-MaxVersion: 4.0
OData-Version: 4.0 Origin: http://localhost:9001 Referer:
http://localhost:9001/ User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS
11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko)
Version/11.0 Mobile/15A372 Safari/604.1 X-CSRF-Token: Fetch
X-Requested-With: XMLHttpRequest Request Payload
--batch_id-1542053070786-11 Content-Type:application/http Content-Transfer-Encoding:binary GET Profile?$skip=0&$top=100 HTTP/1.1
Accept:application/json;odata.metadata=minimal;IEEE754Compatible=true
Accept-Language:de
Content-Type:application/json;charset=UTF-8;IEEE754Compatible=true
--batch_id-1542053070786-11--




Thanks for your advice!



Best regards,
Christoph



Further note regarding search for a workaround: As I am currently searching for a workaround to be able to use the odata.v4 model, I found the following blog post:



https://blogs.sap.com/2015/08/05/disable-csrf-token-for-odata-calls-using-sap-netweaver-gateway/



However, the approach does not seem to work for the odata.v4 model as it has a different interface. There is no setHeaders() function to set custom headers on the datamodel. I therefore tried to set the header up via



$.ajaxSetup(headers: 'X-Requested-With': 'X');



Unfortunately, this also does not work. If someone has the odata.v4 Model running with TEIID or Olingo v4 it would be great if he could give me a feedback on how he had worked around this issue.










share|improve this question




























    1















    I am trying to use SAPUI5 in a SPA to display data from a TEIID/Wildfly ODataV4 service. When SAPUI5 ODATA V4 data model is bound to the service, I run into several errors. I thereby connect via proxy (grunt-connect-proxy2) to the odata service. Basic Auth works. The metadata file above the marked service folder in the attached image (screenshot1) is the actual metadata file of the service which, as you can see, is loaded correctly. So no CORS issue or authorization issue.



    Screenshot1



    Screenshot1



    The issue seems to be related to an CSRF Token request as far as I understand. Seems that Teiid/Wildfly is not answering the CSRF Token fetch request. Is there a way to configure Wildfly to answer the request or alternatively a way to disable CSRF requests for the odata V4 model? I have seen such an option in the constructor of the odata V2 model. How could a working configuration look like?



    The following is a screenshot from the browser log:



    I observed a further issue, from which I do not know if it is related to the previous one (there is also a X-CSRF-Token: Fetch involved), or if a have something more missing somewhere. The second issue happens when I use an aggregation binding to bind a odata collection to a sapui5 list. The response looks like




    Request URL: http://localhost:9001/odata4/svc/my_nutri_diary/$batch
    Request Method: POST Status Code: 406 Not Acceptable Remote Address:
    [::1]:9001 Referrer Policy: no-referrer-when-downgrade Response
    Headersview source access-control-allow-credentials: true
    access-control-allow-origin: http://localhost:9001 cache-control:
    no-cache, no-store, must-revalidate connection: close
    content-encoding: gzip content-length: 125 content-type:
    application/json;odata.metadata=minimal date: Mon, 12 Nov 2018
    20:04:30 GMT expires: 0 odata-version: 4.0 pragma: no-cache server:
    WildFly/11 x-powered-by: Undertow/1 Request Headersview source Accept:
    multipart/mixed Accept-Encoding: gzip, deflate, br Accept-Language: de
    Authorization: Basic SU1TVXNlcjpJTVM0Zm9ydW0l Connection: keep-alive
    Content-Length: 329 Content-Type: multipart/mixed;
    boundary=batch_id-1542053070786-11 Cookie: sidebar_collapsed=false;
    cycle_analytics_help_dismissed=1;
    __utmz=111872281.1539128843.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=111872281.767670437.1539128843.1541866362.1541870562.42 DNT: 1 Host: localhost:9001 MIME-Version: 1.0 OData-MaxVersion: 4.0
    OData-Version: 4.0 Origin: http://localhost:9001 Referer:
    http://localhost:9001/ User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS
    11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko)
    Version/11.0 Mobile/15A372 Safari/604.1 X-CSRF-Token: Fetch
    X-Requested-With: XMLHttpRequest Request Payload
    --batch_id-1542053070786-11 Content-Type:application/http Content-Transfer-Encoding:binary GET Profile?$skip=0&$top=100 HTTP/1.1
    Accept:application/json;odata.metadata=minimal;IEEE754Compatible=true
    Accept-Language:de
    Content-Type:application/json;charset=UTF-8;IEEE754Compatible=true
    --batch_id-1542053070786-11--




    Thanks for your advice!



    Best regards,
    Christoph



    Further note regarding search for a workaround: As I am currently searching for a workaround to be able to use the odata.v4 model, I found the following blog post:



    https://blogs.sap.com/2015/08/05/disable-csrf-token-for-odata-calls-using-sap-netweaver-gateway/



    However, the approach does not seem to work for the odata.v4 model as it has a different interface. There is no setHeaders() function to set custom headers on the datamodel. I therefore tried to set the header up via



    $.ajaxSetup(headers: 'X-Requested-With': 'X');



    Unfortunately, this also does not work. If someone has the odata.v4 Model running with TEIID or Olingo v4 it would be great if he could give me a feedback on how he had worked around this issue.










    share|improve this question


























      1












      1








      1








      I am trying to use SAPUI5 in a SPA to display data from a TEIID/Wildfly ODataV4 service. When SAPUI5 ODATA V4 data model is bound to the service, I run into several errors. I thereby connect via proxy (grunt-connect-proxy2) to the odata service. Basic Auth works. The metadata file above the marked service folder in the attached image (screenshot1) is the actual metadata file of the service which, as you can see, is loaded correctly. So no CORS issue or authorization issue.



      Screenshot1



      Screenshot1



      The issue seems to be related to an CSRF Token request as far as I understand. Seems that Teiid/Wildfly is not answering the CSRF Token fetch request. Is there a way to configure Wildfly to answer the request or alternatively a way to disable CSRF requests for the odata V4 model? I have seen such an option in the constructor of the odata V2 model. How could a working configuration look like?



      The following is a screenshot from the browser log:



      I observed a further issue, from which I do not know if it is related to the previous one (there is also a X-CSRF-Token: Fetch involved), or if a have something more missing somewhere. The second issue happens when I use an aggregation binding to bind a odata collection to a sapui5 list. The response looks like




      Request URL: http://localhost:9001/odata4/svc/my_nutri_diary/$batch
      Request Method: POST Status Code: 406 Not Acceptable Remote Address:
      [::1]:9001 Referrer Policy: no-referrer-when-downgrade Response
      Headersview source access-control-allow-credentials: true
      access-control-allow-origin: http://localhost:9001 cache-control:
      no-cache, no-store, must-revalidate connection: close
      content-encoding: gzip content-length: 125 content-type:
      application/json;odata.metadata=minimal date: Mon, 12 Nov 2018
      20:04:30 GMT expires: 0 odata-version: 4.0 pragma: no-cache server:
      WildFly/11 x-powered-by: Undertow/1 Request Headersview source Accept:
      multipart/mixed Accept-Encoding: gzip, deflate, br Accept-Language: de
      Authorization: Basic SU1TVXNlcjpJTVM0Zm9ydW0l Connection: keep-alive
      Content-Length: 329 Content-Type: multipart/mixed;
      boundary=batch_id-1542053070786-11 Cookie: sidebar_collapsed=false;
      cycle_analytics_help_dismissed=1;
      __utmz=111872281.1539128843.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=111872281.767670437.1539128843.1541866362.1541870562.42 DNT: 1 Host: localhost:9001 MIME-Version: 1.0 OData-MaxVersion: 4.0
      OData-Version: 4.0 Origin: http://localhost:9001 Referer:
      http://localhost:9001/ User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS
      11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko)
      Version/11.0 Mobile/15A372 Safari/604.1 X-CSRF-Token: Fetch
      X-Requested-With: XMLHttpRequest Request Payload
      --batch_id-1542053070786-11 Content-Type:application/http Content-Transfer-Encoding:binary GET Profile?$skip=0&$top=100 HTTP/1.1
      Accept:application/json;odata.metadata=minimal;IEEE754Compatible=true
      Accept-Language:de
      Content-Type:application/json;charset=UTF-8;IEEE754Compatible=true
      --batch_id-1542053070786-11--




      Thanks for your advice!



      Best regards,
      Christoph



      Further note regarding search for a workaround: As I am currently searching for a workaround to be able to use the odata.v4 model, I found the following blog post:



      https://blogs.sap.com/2015/08/05/disable-csrf-token-for-odata-calls-using-sap-netweaver-gateway/



      However, the approach does not seem to work for the odata.v4 model as it has a different interface. There is no setHeaders() function to set custom headers on the datamodel. I therefore tried to set the header up via



      $.ajaxSetup(headers: 'X-Requested-With': 'X');



      Unfortunately, this also does not work. If someone has the odata.v4 Model running with TEIID or Olingo v4 it would be great if he could give me a feedback on how he had worked around this issue.










      share|improve this question
















      I am trying to use SAPUI5 in a SPA to display data from a TEIID/Wildfly ODataV4 service. When SAPUI5 ODATA V4 data model is bound to the service, I run into several errors. I thereby connect via proxy (grunt-connect-proxy2) to the odata service. Basic Auth works. The metadata file above the marked service folder in the attached image (screenshot1) is the actual metadata file of the service which, as you can see, is loaded correctly. So no CORS issue or authorization issue.



      Screenshot1



      Screenshot1



      The issue seems to be related to an CSRF Token request as far as I understand. Seems that Teiid/Wildfly is not answering the CSRF Token fetch request. Is there a way to configure Wildfly to answer the request or alternatively a way to disable CSRF requests for the odata V4 model? I have seen such an option in the constructor of the odata V2 model. How could a working configuration look like?



      The following is a screenshot from the browser log:



      I observed a further issue, from which I do not know if it is related to the previous one (there is also a X-CSRF-Token: Fetch involved), or if a have something more missing somewhere. The second issue happens when I use an aggregation binding to bind a odata collection to a sapui5 list. The response looks like




      Request URL: http://localhost:9001/odata4/svc/my_nutri_diary/$batch
      Request Method: POST Status Code: 406 Not Acceptable Remote Address:
      [::1]:9001 Referrer Policy: no-referrer-when-downgrade Response
      Headersview source access-control-allow-credentials: true
      access-control-allow-origin: http://localhost:9001 cache-control:
      no-cache, no-store, must-revalidate connection: close
      content-encoding: gzip content-length: 125 content-type:
      application/json;odata.metadata=minimal date: Mon, 12 Nov 2018
      20:04:30 GMT expires: 0 odata-version: 4.0 pragma: no-cache server:
      WildFly/11 x-powered-by: Undertow/1 Request Headersview source Accept:
      multipart/mixed Accept-Encoding: gzip, deflate, br Accept-Language: de
      Authorization: Basic SU1TVXNlcjpJTVM0Zm9ydW0l Connection: keep-alive
      Content-Length: 329 Content-Type: multipart/mixed;
      boundary=batch_id-1542053070786-11 Cookie: sidebar_collapsed=false;
      cycle_analytics_help_dismissed=1;
      __utmz=111872281.1539128843.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=111872281.767670437.1539128843.1541866362.1541870562.42 DNT: 1 Host: localhost:9001 MIME-Version: 1.0 OData-MaxVersion: 4.0
      OData-Version: 4.0 Origin: http://localhost:9001 Referer:
      http://localhost:9001/ User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS
      11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko)
      Version/11.0 Mobile/15A372 Safari/604.1 X-CSRF-Token: Fetch
      X-Requested-With: XMLHttpRequest Request Payload
      --batch_id-1542053070786-11 Content-Type:application/http Content-Transfer-Encoding:binary GET Profile?$skip=0&$top=100 HTTP/1.1
      Accept:application/json;odata.metadata=minimal;IEEE754Compatible=true
      Accept-Language:de
      Content-Type:application/json;charset=UTF-8;IEEE754Compatible=true
      --batch_id-1542053070786-11--




      Thanks for your advice!



      Best regards,
      Christoph



      Further note regarding search for a workaround: As I am currently searching for a workaround to be able to use the odata.v4 model, I found the following blog post:



      https://blogs.sap.com/2015/08/05/disable-csrf-token-for-odata-calls-using-sap-netweaver-gateway/



      However, the approach does not seem to work for the odata.v4 model as it has a different interface. There is no setHeaders() function to set custom headers on the datamodel. I therefore tried to set the header up via



      $.ajaxSetup(headers: 'X-Requested-With': 'X');



      Unfortunately, this also does not work. If someone has the odata.v4 Model running with TEIID or Olingo v4 it would be great if he could give me a feedback on how he had worked around this issue.







      sapui5






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 20:11







      Christoph

















      asked Nov 12 '18 at 22:30









      ChristophChristoph

      114




      114






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271027%2fsapui5-odata-v4-odatamodel-with-teiid-11-2-wildfly%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271027%2fsapui5-odata-v4-odatamodel-with-teiid-11-2-wildfly%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Darth Vader #20

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Ondo