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.
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!