首页 新闻 会员 周边

wcf如何实现这样url格式的调用?

0
悬赏园豆:30 [已解决问题] 解决于 2010-09-10 11:16

前几天问过了,可是没得到答案,再发一次……

http://xxx.com/api/?apikey=xxxxxxx&method=getUser

看到有些网站提供的api是这种形式

可是wcf如何做呢?我知道通过设置特性UriTemplate是可以的,可是不能每个方法都去设置特性啊,可不可以有通用的做法?

我有试过提供一个主入口方法

[OperationContract]
string API(string methodName, etc...)
但是因为返回类型是string,所以无论动态调用了哪个方法,都只能返回string了,即无论如何最终的html都会是<string>xxxxx</string>

rad的主页 rad | 初学一级 | 园豆:28
提问于:2010-08-18 11:46
< >
分享
最佳答案
0

[WebGet(BodyStyle=WebMessageBodyStyle.Bare)]

string API(string methdoName,etx.....);

 

[WebGet(BodyStyle=WebMessageBodyStyle.Bare)]

Stream API(string methdoName,etx.....);

收获园豆:30
Launcher | 高人七级 |园豆:45045 | 2010-08-18 11:48
我加了BodyStyle也是一样啊...
rad | 园豆:28 (初学一级) | 2010-08-18 13:47
@rad:换成 Stream.
Launcher | 园豆:45045 (高人七级) | 2010-08-18 15:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册