Click here to Skip to main content
15,894,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WCF Service Hosted on Windows Forms Application.
I have a Client Application(Windows forms application).

I want to send data from Client application to the Windows Forms Application where WCF Service is hosted.

Here is my code:
IMyService.cs

C#
[DataContract]
   public class DataMessage
   {
       [DataMember]
       public string Name { get; set; }
   }
[ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetMessage(string name);

        [OperationContract]
        void BroadcastToClient(DataMessage eventData);
   
    }




Client Code:

ServiceReference1.Service1Client client;
DataMessage message = new DataMessage();
message.Name = textBox1.Text;
client.BroadcastToClient(message);


What should I add in Service.cs, so that this pushes the data to the hosted Application.

What I have tried:

Service.cs:

public void BroadcastToClient(DataMessage eventData)
       {
           MessageBox.Show(eventData.Name);
       }


I have added Messagebox to just see whether its receiving the data from client Application, and its working fine...

Now I want to send it to Hosted Application.
Posted
Updated 2-Jun-16 7:54am

I would advise to start here: Duplex Services[^].

This CodeProject article can also be useful: A Beginner's Guide to Duplex WCF[^].

—SA
 
Share this answer
 
This is the simplest example I could find: WCF example with named pipes
WCF Tutorial - Basic Interprocess Communication - Tech.pro[^]
 
Share this answer
 

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