【发布时间】:2020-12-06 12:54:30
【问题描述】:
我在现有 WCF 服务中有一个运营合同。现在我正在为 WCF REST api 扩展它,我得到了很多错误,服务中的最后一个是关于参数的。我的代码如下:
[OperationContract(Name = "Messages", IsOneWay = true)]
[WebInvoke(Method = "GET",
UriTemplate = "/Messages/?id={id}&fileId={fileId}",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped)]
[Description("Inbound Message")]
void Messages(Guid id, int fileId);
我收到错误:
UriTemplate '/Messages/?id={id}&fileId={fileId}' 无效; 查询字符串的每一部分都必须采用“name=value”的形式, 当 value 不能是复合段时。请参阅文档 UriTemplate 了解更多详情。*
请建议我在 uritemplate 中缺少什么?
【问题讨论】:
-
Selim Yıldız的回复是正确的,“/Messages/?id={id}&fileId={fileId}”是无效的模板字符串,还需要将Guid改为字符串。