Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Calling WCF Service with an out parameter
9 replies. Latest Post by ctsraj on March 19, 2009.
(0)
dotnetmac
Member
28 points
19 Posts
03-17-2008 9:01 AM |
Hi there,
How do i call a WCF web service which has an out parameter,
Example:
My service has the following signature
public List<Entity> ListAll(string languageID, out ResultObject resultObject) { }
When i consume this service in my SL application (code below), i only get to pass the languageID not the resultObject
proxy.ListAllCompleted +=
proxy.ListAllAsync(
SpoonSto...
114 points
37 Posts
03-17-2008 11:19 AM |
The idea of an out parameter is that the method will instantiate the null reference that you pass in. A web service is stateless; therefore the handle that you have on an object that goes into a webservice as a parameter will not be the same as the one that makes it into the webservice server side. The nature of this prevents out parameters.
Instead: Create a return object that is composed of everything you need.
Stomp it!
03-17-2008 1:01 PM |
Hey dude,
The web service is in production environment, so i cannot change it. Please tell me how to pass an out parameter from an SL application
thanx
03-17-2008 1:56 PM |
Oops, I wasn't aware that the proxy could handle such a thing as an out parameter. Pretty cool. Is there a reason that you are writing so much code to access the webservice. Didn't Visual Studio create a proxy class that you can instantiate and call methods on?
StompIt!
03-17-2008 2:21 PM |
This seems to be an odd situation, because looking at the References.cs for a webservice, the out parameter exists in the callbacks but not in the actual calls.
Allen Ch...
Star
13856 points
1,800 Posts
03-19-2008 3:18 AM |
Hi:
If you use output parameters GetDataCompletedEventArgs will have relevant property for you to use. Say the parameter is called param1 you can retrieve it via:
void proxy_GetDataCompleted(object sender, SilverlightApplication1.ServiceReference1.GetDataCompletedEventArgs e) {
//e.param1
}
Regards
03-19-2008 4:42 AM |
First of all the method in SL application doesn't even ask the out parameter.
Say i have a service method GetData(int id, out object test), when i add a service reference, the parameters asked are just the id but not the out parameter.
03-19-2008 5:36 AM |
I tested it and it works fine. I guess what you really need is ref instead of out? Try this:
GetData(int id, ref object test)
venkatgude
2 points
1 Posts
11-27-2008 4:48 AM |
Hi,
How to pass ref paramer from silver light application to webservice.
I declared a method Test(string s ,ref string test)
How to call this method from silverlight
Thanks
Venkat
ctsraj
14 points
2 Posts
03-19-2009 7:10 AM |
Please check the result
{
OMID is the "out" Parameter in my WCF Service.