[ServiceContract(CallbackContract = typeof(IWebSocketTestCallback))] public interface IWebSocketTest { [OperationContract(IsOneWay = true)] Task EncAndSendFinancial(string strRequestAPI); } public interface IWebSocketTestCallback { [OperationContract(IsOneWay = true)] Task OnEncAndSendFinancial(string strRequestAPI); }
Task IWebSocketTest.EncAndSendFinancial(string strRequestAPI) { var callback = OperationContext.Current.GetCallbackChannel<IWebSocketTestCallback>(); return callback.OnEncAndSendFinancial("Hi Alex:"+ strRequestAPI); //pass response API }
var context = new InstanceContext(new WCFServiceCallbackHandler()); var client = new ServiceReference1.WebSocketTestClient(context);
private class WCFServiceCallbackHandler : ServiceReference1.IWebSocketTestCallback { void ServiceReference1.IWebSocketTestCallback.OnEncAndSendFinancial(string strRequestAPI) { Console.WriteLine(strRequestAPI); string filePath = ConfigurationSettings.AppSettings["filepath"].ToString().Trim(); using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine("Message :" + strRequestAPI + "<br/>" + Environment.NewLine); writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)