Download CD Content
After completing this chapter, you will be able to:
Describe the main elements of the WCF Service Model.
Create bindings by using code.
Implement a custom service behavior and add it to a service.
Connect to a service from a client application by using the service contract.
Send messages directly to a service without using a proxy object.
By now, you should have a good understanding of how to create WCF client applications and services and how to configure them so that they can communicate with each other. A compelling feature of WCF is the ability to perform many of these tasks by using configuration files. Behind the scenes, the WCF runtime takes this configuration information and uses it to build an infrastructure that can send and receive messages using specified protocols, encoding them in the appropriate manner, and directing them to the appropriate methods implementing operations in a service.
There will inevitably be occasions when you need to perform configuration tasks programmatically, possibly because an application or service needs to adapt itself dynamically according to its environment without intervention from an administrator or maybe for security reasons if you don’t want a user to be able to modify the configuration for an application. For example, you might not want an administrator to be able to enable or disable metadata publishing for a service. It is also instructive to see the sorts of things the WCF runtime does when it executes your client applications and services. So, in this chapter you will look at how to create and use bindings in code and how to send and receive messages programmatically.