Solved

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

Posted on 2014-03-25
3
423 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

736 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