I'm wondering what's the best approach, and its advantages, when specifying parameters for the Web Service methods. Best to explain it through examples.
In my (SOAP) WebService, used by a Xamarin mobile app, I have a WebMethod SubmitForm(int, TransactionData, List<Answer>)
, where:
int
is the ID of the Project and specifies which Database to connect to,
TransactionData
is a DTO containing data about the user and the form, and
Answer
is a DTO containing the ID and answer for a single question.
Because I have separate tables for TransactionData and Answers, these are fairly unrelated to each other, but I'm considering creating a new DTO, SubmitRequest, which would contain these 3 objects. What are the advantages and disadvantages of these options, apart for readability, and a minuscule overhead of instantiating and extracting from SubmitRequest?
Another situation to consider is a WebMethod which accepts a single primitive type, like int. Would it be better to just let it accept an int, or wrap it in a DTO, that contains just a single property? Frankly, I'm not a fan of the latter, because you end up with DTO for a string, int, etc.
Hence the question, what is the most advantageous for the system? Is there even a difference? Or maybe it's just a matter of personal preference?