How to call SOAP WS from Javascript/jQuery

前端 未结 3 1344
予麋鹿
予麋鹿 2021-02-01 22:10

I would like to call a SOAP WebService directly from Javascript. I have been looking all around but still is unable to have something working. I assumed that i must build the SO

3条回答
  •  梦如初夏
    2021-02-01 22:38

    You cannot send cross domain AJAX requests because of the same origin policy restriction that's built into the browsers. In order to make this work your HTML page containing the jQuery code must be hosted on the same domain as the Web Service (http://192.168.1.5/ws/MyWS/).

    There are workarounds that involve using JSONP on the server, but since your web service is SOAP this cannot work.

    The only reliable way to make this work if you cannot move your javascript on the same domain as the web service is to build a server side script that will be hosted on the same domain as the javascript code and that will act as a bridge between the 2 domains. So you would send an AJAX request to your server side script which in turn will invoke the remote web service and return the result.

提交回复
热议问题