Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.

I want to know some basic flow of the WCF service consumption process in windows phone application.
For example there is one method in the service names GetXMLDetails()...
Now to use that method in windows phone app, first we have to create the service client class object..

C#
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();

 client.GetXMLDetailsCompleted += client_GetXMLDetailsCompleted;
            client.GetXMLDetailsAsync();


I want to know why there is a different procedure for using operation contract method instead of directly using as like in normal ASP, Windows Apps. Mean to say why there is a need to create an event first and then handle the result in the event definition.
Posted

1 solution

Hi SaiKrishna,

As per WCF Service Consume operation and Event Handling Mechanism, You are trying to access the WCF Service Method in Asynchronous Way, so you need to define that on async operation when you gets response from your wcf method, there should be one listener at your client which has handler which handles the response given by WCF service.Hope this thing is clear, so before executing async operation it is mandatory to define that particualr handler which handles your response(
GetXMLDetailsCompleted is event handler in your case ) and do the further processing.


So Basic flow will be

Service Object Creation ---> Response Handler(not required in all case, it only need in case of Asynchronous operation) ---> actual service call from the object created in first step.


Hope Everything is clear to you.
 
Share this answer
 
Comments
Saikrishna35 9-Oct-14 5:07am    
Hi Ashok..Thanks for your reply..
But i want to know why the WCF service consumption process is in asynchronous mode instead of using it directly..
ashok rathod 9-Oct-14 5:17am    
you have both the method available at client side its always not necessary that you need to call async method only.
ashok rathod 9-Oct-14 5:18am    
you will have client.GetXMLDetails() method as well.
Saikrishna35 9-Oct-14 5:20am    
Yes i have that method at client side also, now interestingly it was calling that event multiple number of times.
ashok rathod 9-Oct-14 5:31am    
so remove above two lines of code, which is actually running in async manner, dont call both the things

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900