How to change the Synchronous WCF response to an asynchronous response

al5929

New Member
How do I change the following synchronous WCF response to an asynchronous response.I have been looking at MSDN and codeproject, but still a bit confused.http://www.codeproject.com/Articles/91528/How-to-Call-WCF-Services-Synchronously-and-Asynchrhttp://msdn.microsoft.com/en-us/library/ms731177.aspxThe following code is part of the response from the SVC, cs file:-\[code\]public getQuoteSyncResponse1 getQuoteSync(getQuoteSyncRequest request) { // Create new response getQuoteSyncResponse1 res = new getQuoteSyncResponse1(); res.GetQuoteSyncResponse = new GetQuoteSyncResponse(); res.GetQuoteSyncResponse.Header = new GetQuoteResponseHeaderType(); res.GetQuoteSyncResponse.Response = new GetQuoteSyncResponseType(); // Create and populate header res.GetQuoteSyncResponse.Header.MessageId = request.GetQuoteRequestSync.Header.MessageId; res.GetQuoteSyncResponse.Header.Timestamp = request.GetQuoteRequestSync.Header.Timestamp; res.GetQuoteSyncResponse.Header.QuoteId = request.GetQuoteRequestSync.Header.QuoteId; res.GetQuoteSyncResponse.Header.CarrierId = request.GetQuoteRequestSync.Header.CarrierId; List<RejectionType> rj = new List<RejectionType>(); string _sTotalEmployees = request.GetQuoteRequestSync.Request.Employer.TotalEmployees; int _TotalEmployees = 0; if (int.TryParse(_sTotalEmployees, out _TotalEmployees) == false) { RejectionType rt; rt = new RejectionType(); rt.ReasonCode = "R01"; rt.ReasonDescription = "Invalid Number of Employees"; rj.Add(rt); res.GetQuoteSyncResponse.Response.Rejections = rj.ToArray(); res.GetQuoteSyncResponse.Response.ReceiptStatus = AcceptanceContentType.Reject; return res; } res.GetQuoteSyncResponse.Response.ReceiptStatus = AcceptanceContentType.Success; List<QuoteType> q = new List<QuoteType>(); QuoteType qt; qt = new QuoteType(); qt.PlanId = "P345678"; qt.EEPremium = 1220; qt.EESPPremium = 2222; qt.EEDepPremium = 3333; qt.EEFamilyPremium = 4444; qt.TotalMonthlyPremium = 3456; qt.CoverageEffectiveDate = DateTime.Now; q.Add(qt); res.GetQuoteSyncResponse.Response.Quotes = q.ToArray(); return res;}\[/code\]so this Synchronous response is working. Now, how do I use this to transform it into the asynchronous message?Should I be starting the async method in the cs file? or in the svc file? I am confused...\[code\] public getQuoteAsyncResponse getQuoteAsync(getQuoteAsyncRequest request, AsyncCallback callback, Object state) { // Create new response getQuoteAsyncResponse res = new getQuoteAsyncResponse(); return new getQuoteAsyncResponse(); }\[/code\]I sort of understand about the callback deligator, object state and such, but can someone illustrate this further for me?
 
Back
Top