从JavaScript调用WCF服务 [英] Calling WCF Service from JavaScript

查看:65
本文介绍了从JavaScript调用WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用.NET 4.0开发的WCF Web服务,我需要由Javascript客户端调用。我一直在网上搜索最好的绑定来使这成为可能。大多数答案似乎都指向webhttp,但我担心这是最安全的绑定之一。配置它的最佳方法是什么?

I have a WCF webservice developed with .NET 4.0 which I need to be called by a Javascript client. I have been searching online for the best binding to use to make this possible. Most answers seems to point towards webhttp, but I am concerned as this is one of the lest secure bindings. What is the best way to configure this?

推荐答案

根据我的经验和理解使用jquery从客户端调用wcf服务 ,我想说:

As per my experience and understanding of "invoking wcf service from client side using jquery", i would say:

你可以使用webhttp或basichttp绑定中的任何一个,如果需要使用jquery / javascript调用(肯定是basichttp更好地选择webhttp)。

You can use either of webhttp or basichttp binding if need to invoke using jquery/javascript (surely basichttp better choice over webhttp here).

一个人甚至写了一篇关于codeproject的文章,其中提到使用jquery甚至可以调用wshttp bidning为基础的wcf,我自己没有尝试过,所以不确定但是如果你需要使用wshttp公开您的服务,然后可以在CP上引用此链接:
http://www.codeproject.com/Articles/311908/Calling-WCF-service-exposed-with-different-binding

One person even wrote an article on codeproject where mentioned that using jquery one can even invoke wshttp bidning based wcf, I have not tried it myself, so not sure about it but if you need to expose your service with wshttp, then can refer this link on CP: http://www.codeproject.com/Articles/311908/Calling-WCF-service-exposed-with-different-binding

在我看来我会说:
如果没有业务需要将服务作为休息服务公开,那么就不要去webht tp,再次,如果你的客户端应用程序不是.net应用程序,如果没有必要安全,那么你可以完全避免wshttp,所以按照我会说去basichttp 出价,您可以获得可互操作的服务,如果需要,甚至可以在将来增加安全性。

In my opinion i would say: if there is no business need to expose service as rest one, then don't go for webhttp, Again if your client app is NOT a .net app and if there is no need to have security in place, then you can avoid wshttp totally, so per this i would say go for basichttp bidning, where you get interoperable service and can even add security in future, if needed.

这篇关于从JavaScript调用WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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