我有一个使用基本 http 绑定的 WCF 服务。
如何通过浏览器调用其操作/方法?
您需要将 WebGetAttribute 添加到您的方法中,如下例所示
[OperationContract]
[WebGet(UriTemplate = "/placesList/{userId}",
ResponseFormat = WebMessageFormat.Xml)]
List<Places> GetAllPlacesForUser(String userId)
{
string xml = "";
// build xml here
return xml;
}
现在在浏览器中,您可以像这样调用该方法
http://localhost:8085/GeoPlacesDataService/placesList/10 http://localhost:8085/GeoPlacesDataService/placesList/10
其中 10 是 userId 参数。
Note: 为了添加 WebGetAttribute,您必须引用 System.ServiceModel.Web 命名空间,该命名空间位于单独的程序集中
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)