IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
Expand all | Collapse all

[SOLVED] Calling REST Service with Javascript

webMethods Community Member

webMethods Community Member05/05/16 07:02 AM

webMethods Community Member

webMethods Community Member05/05/16 08:29 AM

  • 1.  [SOLVED] Calling REST Service with Javascript

    Posted 05/05/16 06:44 AM

    I am having this problem with the Integration Server where I am trying to call a REST service using Javascript from Mywebmethods OpenCAF Application where I am faced with the Same Origin Policy problem and i cant get the request to work.

    Keep in mind that i added the Cross Origin Resource Sharing (CORS) headers in the server side service and still not working

    I am using 9.9 Suite


    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/05/16 06:52 AM

    Could you please share the watt settings related to CORS that you have enabled on IS extended settings please?


    #Integration-Server-and-ESB
    #webMethods


  • 3.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/05/16 07:02 AM


  • 4.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/05/16 07:12 AM

    Sorry. The screenshot does not show any CORS related watt settings. Could you please unhide them and then share the details please?


    #Integration-Server-and-ESB
    #webMethods


  • 5.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/05/16 08:04 AM

    @Prasad Thank you for your help. I didnt know about the watt setting, and then I added the remaining settings, and now it works
    Capture.PNG


    #Integration-Server-and-ESB
    #webMethods


  • 6.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/05/16 08:29 AM


  • 7.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/04/17 09:54 AM

    HI,

    I have the same problem. I try to call a service with javascript. Because the website is on port 8585 and the service is on port 5555, the browser says:
    XMLHttpRequest cannot load http://localhost:5555/rest/votingMachine/restServices/saveData?json=… Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8585’ is therefore not allowed access. The response had HTTP status code 403.

    I tried to add
    watt.server.cors.enabled=true
    watt.server.cors.allowedOrigins=http://localhost:8585

    llike mentioned in previous posts, but it is still not working. Is there anything else, I have to configure first?


    #webMethods
    #Integration-Server-and-ESB


  • 8.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/04/17 09:58 AM

    Try these:


    #Integration-Server-and-ESB
    #webMethods


  • 9.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 09/21/20 04:08 AM

    Hi Prasad, would like to know your input on how to send a custom header when a client sends you a OPTIONS request. Basically, the ask is that they will send a custom header with a specific value with OPTIONS to the resource, we should confirm that we received that custom header value they sent with a second custom header value from this side.

    eg: customer header: wh-request-origin: thisistest
    we should send them with: wh-allowed-origin: thisistest

    I posted this same request at some other place with no luck.


    #Integration-Server-and-ESB
    #webMethods


  • 10.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 09/30/20 02:52 AM

    Hey @Kumar_Kumar

    Sorry for late response. Have been busy and missed this post.

    If you know all the fixed headers you are gonna used before hand, then use below to send in your request.

    Access-Control-Allow-Headers: <header-name>[, <header-name>]*
    

    In case, your headers are completely adhoc and not known before hand, then use below in your request:

    Access-Control-Allow-Headers: *
    

    On IS extended settings:
    Use below when you know headers before hand:

    watt.server.cors.supportedHeaders=<header-name>[, <header-name>]*
    

    Use below when they are adhoc and you do not know before hand:

    watt.server.cors.supportedHeaders=*
    

    #webMethods
    #Integration-Server-and-ESB


  • 11.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/04/17 12:04 PM

    Thank you so much :smiley: It finally works


    #webMethods
    #Integration-Server-and-ESB


  • 12.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/04/17 02:51 PM

    Glad to note that it worked. But notice that “watt.server.cors.allowedOrigins” is “*” in the settings I provided, which means any origin can try to access your resources. Change it to have comma separated list of sources which are only allowed to access the resources on your IS.


    #Integration-Server-and-ESB
    #webMethods


  • 13.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/13/20 08:46 AM

    is there a way to display external server log dsp page in a section of the main DSP page.
    I tried doing it. but i got an issue with…

    Load denied by X-Frame-Options: “SAMEORIGIN” from “http://xxxxx:5555/WmRoot/log-server-recent.dsp”, site does not permit cross-origin framing from “http://yyyy:5555/ESBServerLogs/DisplayServerLogs.dsp”

    Can you please provide solution for this…or any other alternative.


    #Integration-Server-and-ESB
    #webMethods


  • 14.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/13/20 08:37 PM

    Hi Sasikanth,

    Do you have any CORS related settings enabled on your IS extended settings and you can also refer to the above mentioned settings.

    Please try it out if that config works.

    HTH,
    RMG


    #Integration-Server-and-ESB
    #webMethods


  • 15.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/15/20 01:09 PM

    got a response as

    Blocked by X-Frame-Options Policy.


    #webMethods
    #Integration-Server-and-ESB


  • 16.  RE: [SOLVED] Calling REST Service with Javascript

    Posted 05/29/20 09:14 AM

    Please try to set the watt.server.cors.allowedOrigins as “*” and restart server. I hope it should work.


    #webMethods
    #Integration-Server-and-ESB