Calling One-Way WCF Service using IOutputChannel

Note: This post is inspired by one of the chapter from book Essential WCF. I tried to put the content in my way. Thanks to the original author. I strongly recommend you to read this post

One way communication pattern allows client to send message to service and forget. Client doesn’t have to wait for the response.

One way WCF Service can be created as below,

using System.ServiceModel;

namespace WcfService1
public interface IService1

void  InsertData();

What all you need to do is to pass parameter to Operation Contract as below,


Service is implemented as below,

namespace WcfService1

public class Service1 : IService1
public void InsertData()
//Insert here


In one way communication two interfaces are very important,


These two interfaces are used to send messages between service and client in one way communication pattern.


At the service side we are using basicHttpBinding and this does not support one-way communication. It is made for Request-reply communication pattern. So you may consider using custom binding made on stack of basicHttpBinding.

static CustomBinding CreateOneWayBinding(Binding baseBinding)
List<BindingElement> elements  = new List<BindingElement>();
elements.Add(new OneWayBindingElement());
return new CustomBinding(elements);


Above function can be used at WCF client side as well to create custom binding supporting one-way communication.

At client side we can call One-Way WCF Service using IOutputChannel. For that you need to add below references to the client project.


You can create at client side one-way communication supporting custom binding as below,


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;

namespace Client
class Program
static void Main(string[] args)
BasicHttpBinding binding = new BasicHttpBinding();
CustomBinding bindingToprfoemOneWay = CreateOneWayBinding(binding);
BindingParameterCollection parameters = new BindingParameterCollection();
Message message = Message.CreateMessage(MessageVersion.Soap11,"urn:sendmessage");
IChannelFactory<IOutputChannel> factory = bindingToprfoemOneWay.BuildChannelFactory<IOutputChannel>(parameters);
IOutputChannel channel = factory.CreateChannel(new EndpointAddress("<a href="http://localhost:10828/Service1.svc">http://localhost:10828/Service1.svc</a>"));

If you are not using custom binding at service side and relying on basicHttpBinding then very likely you will get below exception,


In this way you can make one-way communication call to WCF Service from the client.

I hope this post was useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter or may like Facebook page of my blog If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you

2 responses to “Calling One-Way WCF Service using IOutputChannel”

  1. […] Calling One-Way WCF Service using IOutputChannel […]

  2. […] Calling One-Way WCF Service using IOutputChannel […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at