【发布时间】:2012-07-30 17:06:03
【问题描述】:
我可以这样做吗?
[OperationContract]
[WebInvoke
(
Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/abc{integerParam}"
)
]
ResultStruct abc( int integerParam, CustomClass secondParam );
这里的想法是我可以在 url 中传递第一个参数(整数),但 secondParam 来自 POST。这甚至可能吗?
我从 WCF REST 开始,不确定如何分配参数。任何指示都会有所帮助,谢谢
【问题讨论】:
-
是否有必须使用 WCF 的要求?
-
是的,必须使用 WCF。 @MIke 这个例子并不是我想要做的,它只使用查询字符串。我正在尝试使用查询字符串发布?
-
好的,看看这个。他们有一个发布的正文并接收查询参数。 stackoverflow.com/questions/11261119/wcf-post-with-query-string
-
Thnx 这就是我起初的想法,要么访问查询字符串,要么从代码中发布,但想要第二个意见。 Tx 为您提供帮助。