服务中从JavaScript的HTML调用WCF服务 [英] Call WCF service from JavaScript HTML within service

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

问题描述

我现在有一个数据库上运行的WCF服务。我希望能够使用JavaScript(特别AngularJS)来调用服务方法,并在网页上显示它们。

I currently have a WCF service that operates on a database. I'd like to be able to use JavaScript (specifically AngularJS) to call the service methods and display them in a webpage.

我知道这可以通过使用该服务的单独ASP.NET客户应用程序来完成,但我想有JavaScript的/ HTML是WCF服务项目的一部分。理想情况下,我想用户看到我的网页上运行的服务的时候,而不是像这样:的https://pieterderycke.files.word$p$pss.com/2011/01/service-page-in-internet-explorer.png,但我不知道从哪里开始。

I know this can be done using a separate ASP.NET client application that uses the service, but I'd like to have the JavaScript/HTML be a part of the WCF service project. Ideally, I'd like the user to see my webpage when running the service, rather than something like this: https://pieterderycke.files.wordpress.com/2011/01/service-page-in-internet-explorer.png, but I have no idea where to start.

我要在哪里把我的JS / HTML文件的项目,如何从WCF服务引用它们?是否需要做揭露服务于JS / HTML文件的东西吗?在此先感谢!

Where must I put my JS/HTML files in the project and how do I reference them from the WCF service? Does something need to be done to expose the service to the JS/HTML files? Thanks in advance!

推荐答案

这其实很简单,真的只是添加文件到您的项目的问题。你只需要确保的JavaScript / HTML文件中引用的所有仍然指向正确的位置。如果您使用AngularJS具体而言,添加到项目中,然后再添加自定义的文件。

It's actually rather simple, really just a matter of adding the files to your project. You just need to make sure the references within the JavaScript/HTML files all still point to the right spot. If you're using AngularJS specifically, add that to the project first, then add your custom files.

另外,如果你正在寻找展示运行Visual Studio中的服务时,一个HTML文件,看看这里:<一href=\"http://stackoverflow.com/questions/33370172/displaying-web-page-when-running-wcf-service/33371399#33371399\">Displaying网页时运行WCF服务。

Also, if you're looking to show an HTML file when running the service in Visual Studio, have a look here: Displaying web page when running WCF service.

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

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