Solved

How to pass values by reference in a web service operation?

Posted on 2014-03-25
3
420 Views
Last Modified: 2014-03-31
how can I pass values by reference in a web service operation of Silverlight?
can anyone help me with this?

this is my code...
 
string sCompanyID = txtCompanyID.Text;
                string sUserName = txtUserName.Text;
                string sPassword = txtPassword.Password;
                string sToken = string.Empty;               

                ServiceReference1.udvUserProfile oUserProfile = new ServiceReference1.udvUserProfile();
                ServiceReference1.udvCompanyProfile oCompanyProfile = new ServiceReference1.udvCompanyProfile();

                //convert del saldecimal
                int iSingInReturn = Convert.ToInt32(client.SignInAsync(sCompanyID, sUserName, sPassword, ref sToken, ref oUserProfile, ref oCompanyProfile).Value);

Open in new window


Error:      12      Argument 4 should not be passed with the 'ref' keyword      

thanks in advance...
0
Comment
Question by:Conrado ZAVALA
3 Comments
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 250 total points
ID: 39955286
You're trying to call a webservice and expect to have a value passed by reference?

I guess this is the problem when too much is abstract from the developers.
Unless MS invented some sort of SocketIO thing this is completely impossible.

Calling a webservice is (most commonly) an HTTP request on steroids (SOAP)...
So you send a request and receive a response... that's all...

WCF (and basically all other web service helpers that generate the proxy for you) abstracts you of all this of it looks like everything is integrated and wrapped in some sort of magic but underneath you have a proxy client that seserializes your request to XML, sends the request, the service process it, returns the response, the proxy serializes it back to your response object and there you go...

If you want a variable to be changed, change it from the response.

Cheers!
Alex
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 250 total points
ID: 39955344
Said in other words, when a variable is passed by reference, it's the pointer to the variable that is passed, it's address in memory.

When you are using a Web service, you are calling another computer. Even if you sent it the pointer, it would be useless, since that other computer cannot read into the client.

It is thus not possible to send a variable by reference to a web service.

What is passed back and forth is a copy done through serialization. Thus, when you receive the result back, you need to either copy back the values that were changed into your original object, or scrap it and use the returned object instead.
0
 

Author Closing Comment

by:Conrado ZAVALA
ID: 39966953
thanks...
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question