I too am learning WCF and am new to Web Services and have a very basic question. Please indulge me! The example in the book I'm using (Learning WCF) created a ServiceHost instance specifying a base address for the service (new Uri("http://localhost:8000/HelloIndigo)), which I guess is the location of the class library implementing the service. Then a call to AddServiceEndpoint() is done with the final argument, the relative address, given as "HelloIndigoService". Is the latter nothing more than the name of the class (to be found in the library) that actually implements the service contract? (The class in question DOES bear that name.) Yet that argument is called the "address" which is mightily confusing me. Please help.
Wcf – The relative address of a WCF service endpoint when base address already supplied
endpointsservicewcf
Best Answer
If you're self-hosting, you can have either:
complete, explicit endpoint addresses in your endpoints, e.g.
So your endpoint defines a complete HTTP address
OR:
So in your case, the base address is
http://localhost:8000/HelloIndigo
- so all service endpoints will be "under" that address.The endpoint defines a relative address of
HelloIndigoService
, so those two are put together and the full address in the end will be:This works for self-hosting only (when you have a host application that creates the
ServiceHost
class and opens it for use).When you use IIS to host your service, then the base address is not used / not interpreted - instead, the virtual directory (in IIS) where your
*.svc
file exists defines your service endpoint's address.