what is the use of base address in WCF service
what is the use of base address...i mean what is the meaning of base address? if i omit the base address then what problem can be occur?.
when base address is required?
according to below config entries there are two base addresses...why two base address is required. when people give more base addresses? just see the below 2 base address and tell me why people give two base address why not one...is there any specific reason?
<host> <baseAddresses> <add baseAddress="net.tcp://localhost:1645/ChatServer/"/> <add baseAddress="http://localhost:1648/ChatServer/"/> </baseAddresses> </host>
A base address (one per "scheme" - e.g. one for http, one for net.tcp etc.) can define the "base" of your address - which is really helpful if you intend to specify multiple endpoints.
A base address is never required - it's an optional thing, which can help you simplify your life.
Having a base address makes it possible to specify only the "relative" part that's different for each actual service address.
Imagine you want to have three service endpoints - either you can define them all separately, fully, in a config something like this:
<service name="Test1"> <endpoint name="endpoint1" address="http://yourserver/yourservices/test1/service1" ..... /> <endpoint name="endpoint2" address="http://yourserver/yourservices/test1/service2" ..... /> <endpoint name="endpoint3" address="http://yourserver/yourservices/test1/service3" ..... /> </service>
or you can define the common parts by specifying a base address and then have easier to read "relative" addresses:
<service name="Test1"> <host> <baseAddresses> <add baseAddress="http://yourserver/yourservices/test1/"/> </baseAddresses> </host> <endpoint name="endpoint1" address="service1" ..... /> <endpoint name="endpoint2" address="service2" ..... /> <endpoint name="endpoint3" address="service3" ..... /> </service>
So using a base address can make it easier to specify multiple endpoints - and it can save you some typing.
Also: note that base addresses are really only useful if you're self-hosting your WCF service. If you're using IIS to host your WCF service, then the location of the *.svc file really dictates the "base address" of that service, e.g. having a base address in such a case doesn't really make any difference / doesn't really help at all.