Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the use of base address in WCF service [closed]

Tags:

wcf

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>
like image 443
Thomas Avatar asked Dec 28 '12 12:12

Thomas


People also ask

What is base address in WCF?

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.

What is address in Windows Communication Foundation?

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.

What is address header in WCF?

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.

How many endpoints can a WCF Service have?

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.


1 Answers

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.

like image 62
marc_s Avatar answered Sep 23 '22 21:09

marc_s