Thomas
Thomas

Reputation: 34188

Regarding WCF endpoint address attribute

being new to wcf i often stuck to write endpoint address in config file. sometime i just could not understand what address i should write in endpoint at host end where service will be running. here is one sample endpoint entry....please have a look.

<endpoint address="net.tcp://localhost/ServiceModelSamples/Service1.svc" 
          binding="netTcpBinding" 
          contract="ServiceReference1.IService1">
</endpoint>

<endpoint address="net.tcp://localhost/ServiceModelSamples/service"
          binding="netTcpBinding"
          contract="ServiceReference1.IService1" />

i have couple of question on endpoint address 1) when i should write endpoint address like this way

net.tcp://localhost/ServiceModelSamples/Service1.svc

i guess when we will host our service in IIS then we need to write endpoint address like above one where we need to write our svc file name. am i right?

2) just see the below address

address="net.tcp://localhost/ServiceModelSamples/Service1.svc" 

what is ServiceModelSamples do i need to mention it?

3) suppose i develop wcf service with wcf service application template and host that service in win form apps then how our endpoint address would look like below one

 address="net.tcp://localhost/ServiceModelSamples/service"

do i need to write ServiceModelSamples our project name folder or we can remove it from address like address="net.tcp://localhost/service"

it is very important for me to know that do i need to write our project folder name like ServiceModelSamples

4) when we host wcf service in win form apps then do i need to specify our svc file name with extension.

5) specifically guide me what address i need to write when we host our service in win form apps.

my all above question may sounds very stupid but i have really confusion about address in endpoint. i have no there way to put question here. So please have a look at my 5 points and guide me. thanks

Upvotes: 1

Views: 1419

Answers (1)

I&#241;aki Elcoro
I&#241;aki Elcoro

Reputation: 2181

I think your confusion comes from the differences between IIS Hosting and custom hosting.

When you use IIS to host the service, the service behaves this way:

  • A base address is assigned to the service automatically depending on where the service is hosted in IIS. It uses the same address mapping that a web site uses.
  • The service layer needs to have .svc files to expose service instances through IIS. Those service files are just mapping files that help exposing on IIS.

So to fill the address to a service hosted in IIS from the client you need to:

  • Find out the address that has been assigned by IIS.
  • Complete that address with the Service.svc file name that you want to point to.

However when using custom hosting (through ServiceHost) the service address is totally goberned by the service configuration file:

  • The service can configure a base address to all its endpoint via the baseAddresses setting
  • All endpoints can have a full address or relative address. If relative address is used then the resulting endpoint address will be the baseAddress + endpoints relative address.

When custom hosting you have complete control over the service addresses, so you don't have any of the constraints that you must follow on IIS.

Upvotes: 1

Related Questions