从HTML页面调用WCF服务 [英] Calling WCF service from HTML page

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

问题描述

大家好,

我需要使用带有html页面的wcf服务在sql表中存储名字和姓氏。创建了测试服务并在服务层中编写了数据代码。我从休息客户端测试了它。它工作正常。

现在我想在html页面中调用insert方法。我怎样才能做到这一点?我试过网站/网络应用程序。它的工作正常但不适用于HTML。

请帮我解决这个问题



谢谢



我尝试过:



使用名字和姓氏创建测试服务并从其他客户端插入这些值。它是工作得很好

Hi Guys,
I need to store first and last names in a sql table using wcf service with html page. Created Test Service and wrote data code in service layer. i tested it from rest client. it's working fine.
now i want to call the insert method in html page. How can i do this? i tried with website/web application. it's working fine but not for html.
Please help me to solve this

Thanks

What I have tried:

Created Test Service with first and last names and inserted those values from rest client.It's worked fine

推荐答案

如果它是一个REST服务,那么它由WCF实现的事实是无关紧要的,只是google上关于呼叫休息服务javascript和你的文章找到很多例子



入门·消费一个带jQuery的RESTful Web服务 [ ^ ]
If it's a REST service then the fact that it is implemented by WCF is irrelevant, just google for articles on "call rest service javascript" and you'll find lots of examples

Getting Started · Consuming a RESTful Web Service with jQuery[^]


请参阅我对该问题的评论 - 我强烈建议不要尝试在客户端使用服务。你最好在服务器端做这件事。



但是,如果你有令人信服的理由这样做(我对此表示怀疑),你可以从

向客户端脚本公开WCF服务 [ ^ ](仍然基于ASP.NET),

如何在没有ASP.NET的情况下使用AJAX来使用WCF [ ^ ]。



请注意Microsoft评论此文档可能不代表当前开发的最佳实践。我认为这个说明在这个页面上非常相关。 :-)



-SA
Please see my comment to the question — I strongly recommend not to try to consume services on the client side. You should better do it on the server side.

However, in case you have compelling reasons to do so (I doubt it), you can start with
Exposing WCF Services to Client Script[^] (still based on ASP.NET),
How To Consume WCF Using AJAX Without ASP.NET[^].

Note the Microsoft comment "This document may not represent best practices for current development". I think this note is very relevant on this page. :-)

—SA


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

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