我可以通过使用UriTemplate非字符串WCF RESTful服务? [英] Can I pass non-string to WCF RESTful service using UriTemplate?

查看:212
本文介绍了我可以通过使用UriTemplate非字符串WCF RESTful服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以做以下?

[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.

这篇关于我可以通过使用UriTemplate非字符串WCF RESTful服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆