Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 27-Sep-08 23:23pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
  Print Answers RSS
0 CHill60 320
1 Sarvesh Kumar Gupta 238
2 Sergey Alexandrovich Kryukov 163
3 OriginalGriff 163
4 DamithSL 153


Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 28 Sep 2008
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid