【发布时间】:2015-07-28 10:04:43
【问题描述】:
我有一个 WCF Rest-Service,其方法需要字符串参数。此参数是一个 Uri。为了能够使用 URI 作为 REST 服务的参数,我使用 JavaScript 方法 encodeURIComponent 对 URI 进行编码
http://creativeartefact.org/example/fa9eb3e7-8297-4541-81ec-e9e9be6e6638
变成
http%3A%2F%2Fcreativeartefact.org%2Fexample%2Ffa9eb3e7-8297-4541-81ec-e9e9be6e6638
当我使用普通字符串调用服务时,一切都很好
../liveEvents/qwertz
当我使用编码的 Uri 调用它时(我直接在浏览器中输入了请求),我收到“未找到端点”错误。
../liveEvents/http%3A%2F%2Fcreativeartefact.org%2Fexample%2Ffa9eb3e7-8297-4541-81ec-e9e9be6e6638
知道可能是什么问题以及如何使用 JavaScript 安全地将 URI 作为参数传递给 WCF REST 服务吗?
提前致谢,
弗兰克
编辑:这里是端点方法:
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "liveEvents/{artistUri}")]
IList<LiveEvent> GetLiveEventsList(string artistUri);
【问题讨论】:
标签: javascript wcf rest uri