Sunday 27 September 2009

WCF service endpoint

An endpoint is defined by an address, contract and binding.

A address can be defined in the following ways (in the config file) either as implicit using the base address (which is required to be defined):

<endpoint binding="basicHttpBinding" name="basicHttp" contract="Host.ItecneckService" />

Which would make the service address: "http://localhost:8000/tecneck/"
or as a relative url:

<endpoint address="TecneckService" binding="basicHttpBinding" name="basicHttp" contract="Host.ItecneckService" />

making the url: "http://localhost:8000/tecneck/TecneckService"

or full url:

<endpoint address="http://localhost:8000/tecneck/TecneckService" binding="basicHttpBinding" name="basicHttp" contract="Host.ItecneckService" />

The base address is added like this (under the <service> tag):
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/tecneck"/>
</baseAddresses>
</host>

A Service can have several endpoints but they have to be unique, and differ in either address, contract or transport protocol. There can be several reasons why a service would have multiple endpoints for example:


  • The service implements several contracts, which could each need their own endpoint

  • More the one protocol should be supported

  • same service must be accessible by clients with different binding requirements, possibly related to security, reliable messaging, or transactions.

No comments: