通过将WCF服务转换为JSON使用客户端绑定 [英] Client Side Binding using by Converting the WCF Services to JSON

查看:147
本文介绍了通过将WCF服务转换为JSON使用客户端绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用IIS中托管的WCf服务的要求,例如 http://localhost/someservice.svc . 我们想通过Java脚本使用该Service,并将我的示例数据控件绑定到客户端本身的网格视图. 我认为可以通过序列化和反序列化为JSON并使用数据源并绑定网格控件来完成. 请参考以下链接 http://forums.infragistics.com/forums/p/48035/258346.aspx 我想像上面的链接那样实现我的功能. 您能否指导我完成此任务. 谢谢 问候 巴拉吉(N.Balaji)

解决方案

Balaji

是的,您绝对可以启用WCF服务(无论是否在IIS中)以使用JSON.

您确实需要做出选择:您是要使用ASP .NET AJAX框架中的该服务,还是要创建一个更通用的解决方案,而该解决方案不依赖于该框架在浏览器中的使用? /p>

如果是前者,请使用WebScriptEnablingBehavior.如果是后者,请使用WebHttpBehavior.

对于这两种情况,下面的两个MSDN部分中都提供了详细的说明:

We have a Requirement of Consuming the WCf Services which is hosted in IIS like http://localhost/someservice.svc. We would like to consume that Service via java script and bind my sample data controls called grid view on client side itself. I think this can be done by Serializing and deserialzing to JSON and consume the data source and bind the grid controls. Pls Refer the below link http://forums.infragistics.com/forums/p/48035/258346.aspx I would like to Achieve my func like the above link. Can you pls guide me to achieve this Tasks. Thanks Regards N.Balaji

解决方案

Balaji,

Yes, you can definitely enable your WCF service (whether within IIS or not) to use JSON.

You do need to make one choice: do you want to use that service from the ASP .NET AJAX framework, or do you want to create a more general solution that is not tied down to that framework's usage within the browser?

If it's the former, use WebScriptEnablingBehavior. If it's the latter, use WebHttpBehavior.

For either scenario, detailed instructions are available in the following two MSDN sections:

这篇关于通过将WCF服务转换为JSON使用客户端绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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