在mvc3中通过jquery调用webservice [英] calling webservice through jquery in mvc3

查看:89
本文介绍了在mvc3中通过jquery调用webservice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想通过jquery使用mvc3应用程序来调用web服务。



我在这里如何传递凭证的用户名和密码



希望得到一些帮助





感谢和问候,

Soumya

Hi All,

I would like to call a webservice through jquery using mvc3 application.

Here how could I pass the username and password for credential

Hope some help


Thanks & Regards,
Soumya

推荐答案

试试这个。请确保你必须在页面中添加jQueryplugin < br $> b $ b

Try this.Please make sure that you must add jQueryplugin in your page


.ajax({
url:webserviceUrl,
类型: POST // 这是你应该chage
dataType: application / json; charset = utf-8
用户名: user //
密码: pwd
processData : false
contentType: application / json
成功: function (){
alert( success);
},
错误: function (xhr,ajaxOptions,thrownError){
alert(xhr.status);
alert(xhr.responseText);
},
});
.ajax({ url:webserviceUrl, type: "POST", //This is what you should chage dataType: "application/json; charset=utf-8", username: "user", // password: "pwd", processData: false, contentType: "application/json", success: function () { alert("success"); }, error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(xhr.responseText); }, });





如果您需要更多信息,请点击此链接

http://blog.coreycoogan。 com / 2010/12/17 / calling-asp-net-web-service-asmx-from-jquery / [ ^ ]

希望这有帮助



If you need more information go through this link
http://blog.coreycoogan.com/2010/12/17/calling-asp-net-web-service-asmx-from-jquery/[^]
Hope this helps


首先,这与MVC3没什么关系。

取决于很多东西,尤其是身份验证。您可以 [ ^ ]使用SOAP来自ajax的web服务。您也可以传递凭据(ntlm / kerberos应该是透明的),但这会引发一些安全问题,因为您不应该在客户端存储纯文本(甚至消化的)凭据。

我建议您在服务器端移动此功能,并在服务器应用程序提供的常规正常服务的外壳下将其呈现给客户端。如果客户通过互联网传播,这是唯一可靠的方法,并且无法保证客户端能够以可靠的方式使用第三方服务。
First of all, this has little to do with MVC3.
Depends on many things, especially the authentication. You can[^] consume SOAP web services from ajax. You could pass credentials too (ntlm/kerberos should be transparent), but that raises several security issues, since you should never store plain text (or even digested) credentials on client side.
I suggest you move this functionality on server side and present this to the client under the cloak of the regular normal services provided by your server application. This is the only reliable approach if clients are spread over the internet, and there is no guarantee that the client will be able to consume the third party service in a reliable manner.


这篇关于在mvc3中通过jquery调用webservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆