WCF and HTTP GET

4

我的WCF服务公开了这个函数

public SerialNumberInfo GetSerialNumberInfo(string serialNumber) { }

有没有办法在我的WCF服务上启用HTTP GET?例如:

http://localhost:8004/MyService/GetSerialNumberInfo?serialNumber=4
2个回答

4
是的,您需要在WCF服务上使用webHttpBinding
有关WCF中REST支持的更多信息,请参见WCF REST入门套件。 如果您在IIS中托管服务,则需要为REST服务创建一个单独的*.svc文件(我们称之为RESTService.svc),其中包含:
<%@ ServiceHost Service="YourServiceName" Language="C#" debug="False"
    Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

现在你应该能够连接到该URL。
http://localhost:8004/MyService/RESTService.svc

以REST方式获取你的数据。

Marc


3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接