Page view counter
Calling WCF Service with an out parameter Subscribe to this thread
Last post 03-19-2009 7:10 AM by ctsraj. 9 replies.
Sort Posts:
03-17-2008 9:01 AM
Calling WCF Service with an out parameter

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

Binding binding = new BasicHttpBinding();

EndpointAddress address = new EndpointAddress("http://localhost:5309/ContextManager/EntityService.svc");

ContextManager.EntityService.EntityServiceClient proxy = new ListViewDataGrid.ContextManager.EntityService.EntityServiceClient(binding, address);

proxy.ListAllCompleted += new EventHandler<ListViewDataGrid.ContextManager.EntityService.ListAllCompletedEventArgs>(proxy_ListAllCompleted);

proxy.ListAllAsync("en-US"); // it is not asking for the ResultObject parameter.

 

Thanx in advance

 

dotnetmac

Loading...
Joined on 07-03-2006
Posts 19
03-17-2008 11:19 AM
Re: Calling WCF Service with an out parameter

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!

SpoonStomper

Loading...
Joined on 03-13-2007
Posts 37
03-17-2008 1:01 PM
Re: Re: Calling WCF Service with an out parameter

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

dotnetmac

Loading...
Joined on 07-03-2006
Posts 19
03-17-2008 1:56 PM
Re: Re: Calling WCF Service with an out parameter

Hey dude,

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!

SpoonStomper

Loading...
Joined on 03-13-2007
Posts 37
03-17-2008 2:21 PM
Re: Re: Calling WCF Service with an out parameter

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.

SpoonStomper

Loading...
Joined on 03-13-2007
Posts 37
03-19-2008 3:18 AM
Re: Calling WCF Service with an out parameter

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

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Allen Chen – MSFT

Loading...
Joined on 03-16-2007
Posts 1,761
03-19-2008 4:42 AM
Re: Re: Calling WCF Service with an out parameter

Hi there,

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.

dotnetmac

Loading...
Joined on 07-03-2006
Posts 19
03-19-2008 5:36 AM
Marked as Answer
Re: Re: Calling WCF Service with an out parameter

Hi:

  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)

 

Regards

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Allen Chen – MSFT

Loading...
Joined on 03-16-2007
Posts 1,761
11-27-2008 4:48 AM
Re: Re: Calling WCF Service with an out parameter

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 

 

venkatgude

Loading...
Joined on 10-21-2008
Posts 1
03-19-2009 7:10 AM
Re: Re: Calling WCF Service with an out parameter

Please check the result

void client_GetCitationCollectionCompleted(object sender, GetCitationCollectionCompletedEventArgs e)

   diseaseEvent(sender, new DiseaseEventArgs(e.OMID));

OMID is the "out" Parameter in my WCF Service.

ctsraj

Loading...
Joined on 03-19-2009
Posts 2
Microsoft Communities