Click here to Skip to main content
15,065,044 members
Please Sign up or sign in to vote.
4.91/5 (4 votes)
See more:
Hello everyone,


Supposing I am writng a web services client using managed code. My question is what is the differences between passing by value and passing by reference, when we pass parameter to a web services web method call?

My confusion is, in traditional senses, passing by reference means passing only a pointer, and modification is impacted on the original object. Passing by value means passing a new copy of original object, and modification is not impacted on the original object. -- But for web services, no matter pass by value or pass by reference of an object, I think it is always made a new copy and not pointer across the network to web services server (since pointer address is only meaningful for local process on local machine)?

What is the actual differnces between passing by reference and passing by value when making a web services call?


thanks in advance,
George
Posted

George_George wrote:
Passing by value means passing a new copy of original object


That only applies to value types. For a reference type you will be passing a copy of the reference, not a copy of the object.

For web services you will always pass a serialised copy of the object, and if it's a ref parameter, it will send back a serialised copy of the updated object which will replace the data in the original object.

   
This article[^] explains it.
Basically .NET remoting allows passing an object by "marshal-by-value" (for (I)Serializable objects) or "marshal-by-reference" (for objects that inherit from System.MarshalByRefObject). The latter is slightly different than just passing a pointer around, but it kind of simulates this scenario in .NET remoting.

regards
   



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900