Calling Services Without a Contract

Contracts are largely an illusion about the kinds of messages that can be exchanged between a client and a server. From a practical perspective, a service can describe itself using any contract it likes but the true measure of compatibility comes from being able to exchange data. The easiest way to experience this observation is to build and send some messages without using any contracts.

I've talked a lot in the past about sending messages directly using channels, which are a very thin wrapper around the semantics of sending and receiving. You don't have to go all the way to using channels to experience contract-less programming though. The standard ChannelFactory class for building proxy objects has a limited built-in knowledge about the IRequestChannel shape. In essence, this is a way to send messages in a contract-oriented programming model without actually using contracts.

Quite a few systems require sending and receiving messages but lack any support for dealing with contracts. It can be difficult to acclimate yourself to this style of programming, but it can be done to a large degree without having to give up the conveniences of a nice programming model.

Next time: Serializing UniqueId

Comments (4)

  1. Dilip says:

    This post has been tremendously helpful. Thanks! Sometimes one knows what they’re looking for but the terms to search for, actually elude you 🙂

  2. How can I put together a stack trace that goes between service operations on different services? In a

  3. sibi says:

    I am developing a WCF application. I want my WCF service read data directly from a port and my WCF client write data directly to a port. Is it possible? If so how?

  4. Hi Sibi,

    You should look at the WSE TCP interop sample ( as an example of how to do raw socket communication with WCF.

Skip to main content