I am working on a web application that consumes a web service. Web service is written in .NET.
I want to know whether using a reference parameter for a Web method is a good practice or not?
views:
131answers:
2It is best to have the ws message based.
You can still be doing so implicitly when you use multiple parameters, there is still the message you are receiving with those. Just keep them separated, if you need multiple outputs return a simple result class for the operation.
You can use ref and out params with WCF services, but under the hood they're wrapped up.
Anything passed to a WebMethod or service has to be serialised - you can make it behave as if it is a ref or out by wrapping it in something that sets the values back, but this is messy.
You're better off with a record class - a simple serialisable class that's basically just a list of auto properties that's the return of the WebMethod.
This results in extra classes, but is much easier to maintain.