Jal*_*aer 36
您需要将WebGetAttribute添加到您的方法,如下面的示例
[OperationContract]
[WebGet(UriTemplate = "/placesList/{userId}",
ResponseFormat = WebMessageFormat.Xml)]
List<Places> GetAllPlacesForUser(String userId)
{
string xml = "";
// build xml here
return xml;
}
Run Code Online (Sandbox Code Playgroud)
现在在浏览器中,您可以像这样调用方法
http:// localhost:8085/GeoPlacesDataService/placesList/10
其中10是userId参数.
注意:为了添加WebGetAttribute,您必须引用System.ServiceModel.Web命名空间,该命名空间位于单独的程序集中
小智 6
添加上述代码之后,端点属性在被修改的web.config,binding="webHttpBinding"和behaviorConfiguration="webHttp".