WCF Service Namespaces

Since I seem to forget this on a regular basis, I wanted to leave a note to myself for future reference. I also want to post a link to the Tech Talk blog where I found most of this information.

By default, WCF assigns the namespace "http://tempuri.org/" to all web service operations. (For more information on tempuri.org, see the W3C Note on WSDL.) Typically you will want to assign your own namespace to uniquely identify any web services you have deployed. Since WCF has a (seemingly) infinite number of configuration options, there are no fewer than three places you need to set the namespace to keep WCF from using the default tempuri.org.

The first is on the ServiceContract attribute. Set the namespace in the attribute constructor.

[ServiceContract(Namespace = @"http://someservice.example.com/")]
public interface ISomeService

The second place it needs to be set is on the ServiceBehavior attribute. Again, set the namespace in the attribute constructor.

[ServiceBehavior(Namespace = @"http://someservice.example.com/")]
public class SomeService : ISomeService

The third and final place it needs to be set is the bindingNamespace attribute on the endpoint element in the App.config file.

<endpoint bindingNamespace="http://someservice.example.com/"...>
.net activemq adapters akka amazon amqp apache api appfabric architecture asp.net authentication azure biztalk bpm caching camel cep cloud cloud computing cqrs data formats design eai edi esb esb toolkit events governance hateoas html http hypermedia integration java jax-rs jms json linked data links linux mapping masstransit media types messaging microdata monitoring msmq mule node.js nservicebus oauth odata open source orchestration patterns powershell pubsub python queues rabbitmq rdf rdfa resources rest resteasy routing rpc ruby security semantic web service bus services sesame signalr soa soap sparql spring streaminsight testing topics transactions transformation uri versioning videos wcf wcf data services wcf web api web web api web services websockets wf windows workflow xml xsd zeromq