在POST而不是GET中使用OData参数查询WCF服务 [英] Querying WCF Services with OData Params in POST instead of GET

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

问题描述

我们叫wcf svcs(不是我们的),我们正在使用gets搜索产品数据库.

We call wcf svcs (not ours) and we're using gets for searching a product database.

示例: http://foo.com/SearchProducts.svc ?$ skip = 0 $ take = 10 $ includeTotalCount =是

Example: http://foo.com/SearchProducts.svc?$skip=0$take=10$includeTotalCount=true

我们正在传递Odata参数来分页SearchProducts svc的结果. svc已更改为POST,因为我们的过滤器之一"skus"有时很大(成百上千的skus),这会由于uri太大而导致GET中断.我们认为最简单的解决方案是将呼叫更改为帖子,但现在似乎没有使用Odata参数.

We were passing the Odata parameters to page the results of the SearchProducts svc. The svc has been changed to a POST because one of our filters "skus" is sometimes huge (hundres of skus) which causes the GET to break because the uri is too large. The easiest solution we thought was to just change the call to a post but now the Odata params dont seem to be used.

在执行POST时是否需要以其他方式发送这些参数?

Do these params need to be sent in a different manner when doing a POST?

推荐答案

兼容的OData服务将不支持查询查询的POST谓词(除非您使用POST隧道,但是无论如何您都将达到URL限制).因此,我想知道它对您有何作用.

Compliant OData service will not support POST verb for queries (unless you use POST tunneling, but then you're going to be hitting the URL limit anyway). So I wonder how it works for you at all.

URL大小限制可以通过以下几种方法来克服:

The URL size limit can be overcome using several approaches:

  • 简化查询表达式.显然,这只能走得很远,但这通常是最好的解决方案,因为它也可能会加快查询的执行速度.
  • 改为使用批处理.您可以批量发送GET请求.在这种情况下,URL的长度不是问题,因为查询URL是在批处理的有效负载中发送的.
  • 为您正在使用的复杂查询定义服务操作(但由于您不拥有该服务,因此这可能不是一个很好的解决方案).

这篇关于在POST而不是GET中使用OData参数查询WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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