Solved

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

Posted on 2014-03-25
3
422 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 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