0845 757 3888 · info@xpertise.co.uk

Technology, training, learning and development blogs

How easy is it to change the bindings of a WCF service from Http to tcp ?

I have written a number of posts looking into the basics of Windows Communication Foundation WCF. I have provided an overview of the technology (and wargaming), shown you how to create a simple WCF service and client. I have also looked into hosting services. I think it’s about time I covered bindings.

 

So I have written my flight service for Xpertise Airways and it is called by client applications over the intranet.

In the short term we will only use the service on the intranet and the administrator feels that we would get better performance if we used tcp instead of Http.

Notice that I said administrator. I have moved on to other things. I am currently developing an Eco Cycle Grader © (the name needs a little work). It is a piece of equipment that helps me keep my sand arena free of weeds. Anyway that story is for another day.

Back to the administrator. It is out of the question for me to change the bindings as I am busy. It would also be impractical and probably foolish to permit the administrator to use Visual Studio to complete the task.

So instead we give them the Windows Service Config Editor (svcconfigeditor.exe). This is the same tool that can be launched from within Visual Studio 2008 and it is a more convenient way to edit config files.

  

Change the service bindings

The administrator runs svcconfigeditor.exe and opens up the App.config file for the service.

Use scvconfigeditor.exe to edit app.config

 

They change the binding of the service’s endpoint to netTcpBinding.

Change the binding of the service’s endpoint to netTcpBinding

 

And  then change the base address to start with net.tcp rather than http.

Change the base address to start with net.tcp rather than http

Finally they save the config file as their work here is done.

  

Change the client bindings

In WCF it is essential that client bindings match those of the service they are calling. After all there would be no point using http to call into a service that only uses tcp.

So the administrator uses svcconfigeditor.exe to open up the App.config on each client in turn.

In a future post I will look at alternatives to having an administrator actually have to update multiple client config files !

They change the binding of the service’s endpoint to netTcpBinding.

Change the address to start with net.tcp rather than http

 

 

And  then change the address to start with net.tcp rather than http.

Change the binding of the service’s endpoint to netTcpBinding

Note that the configuration name (WSHttpBinding_IFlightService) was generated when the service’s reference was added to the client application originally and was derived from the service’s App.config. It would be better to have used a more generic name in the service’s App.config file before discovery.  However it is doing no harm here and so we will leave the name alone.

 

Is that it ?

Yep. That’s it. Simply change the binding and address in each config file and the applications keep on working.

So, how easy is it to change the bindings for a WCF service ?

Very !

 

Training ?

Should you require training in WCF we (Xpertise Training Limited) currently offer the following course: Complete Windows Communication Foundation (Premium Series)