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 WCF service is a collection of endpoints, where each endpoint has a unique address. The endpoint address and binding defines where and how the endpoint listens for incoming requests. In addition to the endpoint addresses, the service itself has an address, which is called the base address.
A WCF client connects to a WCF service via an endpoint. Each service exposes its contract via one or more endpoints. An endpoint has an address (which is a URL specifying where the endpoint can be accessed) and binding properties that specify how the data will be transferred.
In WCF, these reference parameters are modeled as instances of AddressHeader class. In this sample, the client adds a reference parameter to the EndpointAddress of the client endpoint. The service looks for this reference parameter and uses its value in the logic of its "Hello" service operation.
The service configuration has been modified to define two endpoints that support the ICalculator contract, but each at a different address using a different binding.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With