Solved

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now