Simplest SOAP example

前端 未结 13 1658
死守一世寂寞
死守一世寂寞 2020-11-22 01:32

What is the simplest SOAP example using Javascript?

To be as useful as possible, the answer should:

  • Be functional (in other words actually work)
  • <
相关标签:
13条回答
  • 2020-11-22 02:20

    This cannot be done with straight JavaScript unless the web service is on the same domain as your page. Edit: In 2008 and in IE<10 this cannot be done with straight javascript unless the service is on the same domain as your page.

    If the web service is on another domain [and you have to support IE<10] then you will have to use a proxy page on your own domain that will retrieve the results and return them to you. If you do not need old IE support then you need to add CORS support to your service. In either case, you should use something like the lib that timyates suggested because you do not want to have to parse the results yourself.

    If the web service is on your own domain then don't use SOAP. There is no good reason to do so. If the web service is on your own domain then modify it so that it can return JSON and save yourself the trouble of dealing with all the hassles that come with SOAP.

    Short answer is: Don't make SOAP requests from javascript. Use a web service to request data from another domain, and if you do that then parse the results on the server-side and return them in a js friendly form.

    0 讨论(0)
提交回复
热议问题