我可以通过使用UriTemplate非字符串WCF RESTful服务?可以通过、字符串、RESTful、UriTemplate

2023-09-02 10:28:02 作者:哈哈大笑

我可以做以下?

[OperationContract]
[WebGet(UriTemplate = "/foo/{id}")]
string GetFoo(int id);

我想我的服务,充当REST风格的服务和RPC样式的SOAP服务。 如果可能的话,我想保留INT如int,而不是用手做解析。

I'd like my service to function as both RESTful service and RPC-style SOAP service. If possible I'd like to retain int as int, and not do parsing by hand.

推荐答案

如果我没有记错,在路径UriTemplate变量总是在使用WebGet或WebInvoke解析字符串。你只能绑定UriTemplate变量为int,long等等,当他们在Uri​​Template的查询部分。

If I remember correctly, UriTemplate variables in the path always resolve to strings when using WebGet or WebInvoke. You can only bind UriTemplate variables to int, long, etc. when they are in the query portion of the UriTemplate.

 
精彩推荐
图片推荐