简体   繁体   English

如何在JavaScript中使用Web服务

[英]How to consume webservice in javascript

please tell me how to consume webservice (.net) using javascript. 请告诉我如何使用javascript使用网络服务(.net)。

its SOAP. 它的SOAP。

Thanks 谢谢

You use AJAX. 你使用AJAX。

In particular the XMLHttpRequest object. 特别是XMLHttpRequest对象。

Look at the jQuery ajax API - it makes AJAX easier to use. 看一下jQuery ajax API-它使AJAX易于使用。

I don't think there is a Javascript library that consumes SOAP out of the box. 我认为没有一个Javascript库可以直接使用SOAP。 Dojo offers a lot of functionality in that direction, RPC-calls for example, and is probably the one that comes closest. Dojo在这个方向上提供了很多功能,例如RPC调用,并且可能是最接近的功能。 IBM did some work there that you might want to check out. IBM在那里做了一些你可能想要检查的工作。

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. 这个(包括Dojo)是很多非常重要的东西要学习,但SOAP是一个讨厌的野兽,如果你真的需要与JS接口到SOAP服务,你将不得不投入一些时间。

See: 看到:

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

SOAP Requests in Dojo Dojo中的SOAP请求

Both .asmx and .svc (wcf) expose javascript enabled bindings - this is easy to find on the internet. .asmx和.svc(wcf)都暴露了启用javascript的绑定 - 这很容易在互联网上找到。

Example: 例:

Normally you just append /js to the url of the endpoint and javascript providing a proxy is returned. 通常,您只需将/ js附加到端点的url,并返回提供代理的javascript。

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 . 此代理代码依赖于ASP.NET AJAX框架,但您可以通过使用此填充程序轻松地将其与任何其他启用Ajax的框架一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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