在 Soap 请求中传递动态过滤器参数
我有一个返回 User 对象数组的肥皂请求。现在我想添加过滤器参数,例如“har”等用户名和/或 10 到 20 之间的 numberOfLogins。基于此参数,我构建一个查询并获取结果。但问题是我无法在 SOAP 请求中传递这个动态数量的过滤器参数。我该怎么做?我尝试使用 Map 来获取过滤器名称和值,但没有成功。还尝试了数组,但后来我无法决定必须对哪个进行过滤。
我们显示这种形式出现在我们的网站上。其中所有字段都是可选的,因此用户可以在全部或部分字段中输入值。我想获取用户在表单中输入的值仅针对那些填充了值并且不希望请求中包含其他参数的字段。所以这里参数的数量不是固定的。因此,在不知道参数数量的情况下,我无法决定在这种情况下采用的方法参数。我应该采取哪种论证呢?我无法在参数中采用字符串数组,因为我还需要知道字段的名称(用户在其中输入了值)及其值。我尝试过将 Map 作为参数,但没有成功。
I have a soap request returning array of User objects. Now I want to add filter parameters i it like userName like 'har' and/or numberOfLogins between 10 to 20. Based on this parameters I build a query and get results. But the problem is I'm not able to pass this dynamic number of filter parameters in SOAP request. How can I do this? I have tried taking Map to have filter name and value but it did not worked. Also tried Array but then I was not able to decide which I have to do filter on.
We are showing this kind of form in our site. In which all fields are optional so user can enter values in either all or some of them. I want to get the values user has entered in the form for only those fields which are filled with values and do not want other parameters in request. So here n*umber of parameters are not fixed*. So without knowing the number of parameters I am not able to decide the method parameters to take for such a case. Which kind of argument should I take for this. I can not take array of strings in arguments as I also need to know the name of the field (in which user has entered value) with it's value. I have tried taking Map as an argument but did not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要的是一种描述查询来过滤用户对象的方法。
您必须为此创建一个自定义类型,并在其中定义规则:
您将需要字段的名称、字段的值以及适用于它的操作(用户名
;
某些内容、登录次数<之间>
某些内容和其他内容等)。因此,请求将如下所示:
根据您所描述的内容,简单的情况是“AND”所有这些条件来获取过滤器。但此外,您还可以使用“OR”组合、“NOT”等。
棘手的部分是为此类型定义 XML 模式(对输入进行正确的验证)。如果这很麻烦,您可以使用任何元素或任何类型 其中,尽管我强烈建议反对。
查看协作应用程序标记语言 (CAML) 的查询架构 寻求灵感。希望这有帮助!
I think what you need is a way to describe the query to filter the User objects.
You will have to create a custom type for this and inside it define the rules:
You will need the name of the field, the value/values for the field as well as the operation that applies for it (username
<equals>
something, number of logins<between>
something and something else etc).So a request will look something like this:
From what you are describing, the simple case is to "AND" all those conditions to get your filter. But additionally you could have "OR" combinations, "NOT" etc.
The tricky part will be to define the XML schema for this type (to do a proper validation of the input). If that's a hassle, you could have a query tag with any element or any type in it, although I strongly suggest against it.
Have a look at the Query schema of Collaborative Application Markup Language (CAML) for an inspiration. Hope this helps!