Getting Rid of TempUri in WCF

Everyone of has seen it; the default namespace TempUri reference
in our otherwise neatly published WSDL, looks like an out of place
not-so-thought-out part of your otherwise ironclad contract. Hence the question
arises, how to get rid of it and put your company’s corresponding namespace in

In the asmx services, it was rather easy to do it; just
modify your webservice attribute.

[WebService(Namespace = "")]

However, in the new uncharted waters of WCF, things are wee
bit more complex than this. Now you’d need to do it in multiple places. The
point to remember is that an endpoint has an associated behavior with it.

The web.config file.

 Service Endpoint
<endpoint address=""                                                                                                                                           binding="basicHttpBinding"

Behavior Endpoint
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" bindingNamespace=""/>

Also, for the general namespace changes, you need to specify
the attribute as follows.

namespace Acme.Services.WCFNamespaceSample
(Namespace = "Acme.Services.WCFNamespaceSample")]
                public class Service :


namespace Acme.Services.WCFNamespaceSample
= "Acme.Services.WCFNamespaceSample")]
                public interface IService

This should do the magic. Following source code is a good
place to start. (4.1 KB)


One thought on “Getting Rid of TempUri in WCF

Comments are closed.