WCF 方法发送 POST 而不是 GET [英] WCF method sending POST instead of GET

查看:44
本文介绍了WCF 方法发送 POST 而不是 GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个访问 REST API 的 WCF 客户端.API 要求对某个调用使用 GET,因此我对该方法使用了 [WebGet] 属性.但是,当我调用该方法时,产生的实际调用是 POST(使用 Fiddler 查看).我的合同如下:

I'm trying to create a WCF client that accesses a REST API. The API requires that a GET be used for a certain call, so I'm using the [WebGet] attribute for the method. However when I call the method, the actual call that is produced is a POST (viewed by using Fiddler). My contract is as below:

[OperationContract]
[WebGet(UriTemplate = "/statuses/public_timeline.json",
BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
List<Status> PublicTimeline();

我也尝试过将 [WebInvoke] 与 GET 方法一起使用,但没有成功.

I've also tried using [WebInvoke] with a method of GET but with no success.

推荐答案

我使用一个 WCF 服务来做一些工作,然后调用另一个 WCF 服务.这是存在上述问题的第二项服务.问题原来是第一个服务是如何实现的.

I was using a WCF service to do some work and then call another WCF service. It was the second service that had the issue mentioned above. The problem turned out to be how the first service was implemented.

解决方案在这里:http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/03a2b109-c400-49d4-891e-03871ae0d083/#416d85a-bc-6a-8a6d-5d6b09db97b6

这篇关于WCF 方法发送 POST 而不是 GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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