前面介绍过《Step by Step 创建一个WCF Service》和《使用WCF的Trace与Message Log功能》,本文介绍一下如何用JavaScript来调用WCF Service。
WCF Service的代码如下:
IHelloService.cs
![复制代码](https://i-blog.csdnimg.cn/blog_migrate/69c5a8ac3fa60e0848d784a6dd461da6.gif)
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
namespace HelloService
{
[ServiceContract(Name = "IHelloService")]
public interface IHelloService
{
[OperationContract(Name="GetMessage")]
string GetMessage(string name);
[OperationContract]
Employee GetEmployee(int id);
}
}