简体   繁体   中英

How to consume webservice in javascript

please tell me how to consume webservice (.net) using javascript.

its SOAP.

Thanks

You use AJAX.

In particular the XMLHttpRequest object.

Look at the jQuery ajax API - it makes AJAX easier to use.

I don't think there is a Javascript library that consumes SOAP out of the box. Dojo offers a lot of functionality in that direction, RPC-calls for example, and is probably the one that comes closest. IBM did some work there that you might want to check out.

This (including Dojo) is a lot of non-trivial stuff to learn but SOAP is a nasty beast, if you really need to interface to a SOAP service with JS you will have to invest some time.

See:

http://www.ibm.com/developerworks/web/library/wa-dojowebresponse/index.html?ca=drs-

SOAP Requests in Dojo

Both .asmx and .svc (wcf) expose javascript enabled bindings - this is easy to find on the internet.

Example:

Normally you just append /js to the url of the endpoint and javascript providing a proxy is returned.

This proxy code relies on the ASP.NET AJAX framework, but you can easily use it with any other ajax-enabling framework by using this shim .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM