?
Solved

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

Posted on 2014-03-25
3
Medium Priority
?
427 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 750 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 750 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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