我有一个需要字符串参数的方法的WCF Rest-Service。这个参数是一个Uri。为了能够使用URI作为REST服务的参数,我使用了JavaScript方法encodeURIComponent方法来编码URI如何使用URI参数调用WCF REST服务
http://creativeartefact.org/example/fa9eb3e7-8297-4541-81ec-e9e9be6e6638
变得
http%3A%2F%2Fcreativeartefact.org%2Fexample%2Ffa9eb3e7-8297-4541-81ec-e9e9be6e6638
当我调用服务以正常字符串,一切都很好
../liveEvents/qwertz
当我用编码的Uri(我直接在浏览器中输入请求)调用它时,我得到一个“no en dpoint发现“错误。
../liveEvents/http%3A%2F%2Fcreativeartefact.org%2Fexample%2Ffa9eb3e7-8297-4541-81ec-e9e9be6e6638
任何想法可能是什么问题以及如何安全地将URI作为参数传递给WCF使用JavaScript的REST服务?
由于提前,
弗兰克
编辑:这是端点法:
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "liveEvents/{artistUri}")]
IList<LiveEvent> GetLiveEventsList(string artistUri);
我在问题中添加了方法签名。使用?artistUri =没有帮助。即使使用/?artistUri = qwertz的测试请求现在也会失败,并显示“找不到端点”错误。 – Aaginor
所以,基于你的问题,你的GetLiveEventsList方法响应Get动词。 您可以使用http:// yourdns/liveEvents /?artistUri = qwertz调用在浏览器中打开的方法吗?它工作吗? –
不,这不起作用。我得到了Endpoint-not-found-error – Aaginor