Working with Address

Working with Address

DOI: 10.4018/978-1-5225-1997-3.ch004
OnDemand:
(Individual Chapters)
Available
$37.50
No Current Special Offers
TOTAL SAVINGS: $37.50

Chapter Preview

Top

Address In Wcf

Each address type can have different formats as shown in Figure 1. As shown in Figure 1, the left hand side contains three type addresses and each address can be written by using different formats of address mentioned in right hand side of the Figure 1. This figure clears the ambiguity between the address type and address format. An address contains several components which can be understood by following example.

Figure 1.

WCF Addresses

978-1-5225-1997-3.ch004.f01

The address in the below example is divided into three parts mentioned as numbers 1, 2 and 3.

  • 1 3

  • http: //localhost:8080/CalculatorDemo

  • 2

    • 1.

      Scheme/Protocol: This is the first part which contains protocol for communication. In this example the protocol/scheme is http. It can be written based on the binding selected by the programmer. For instance, if binding is BasicHttpBinding or wsHTTPBinding the protocol can be http. But if the binding is other netTcpBinding then protocol cannot be http.

    • 2.

      Name of Machine: It is the second part written after the protocol. It can be machine name or domain name or IP address of the service on which it is hosted. The name localhost or loop back IP address 127.0.0.1 both are also valid values for this component. After a machine name port number can also be specified using a colon as separator. The port number is optional. Default port is 80. So if you don’t specify the port number it will consider it as 80. In windows OS, IIS runs on port number so it is advisable to use the port number other than 80 for the service address to avoid any conflict. For instance the address

      • a.

        http: //localhost/CalculatorDemo and

      • b.

        http: //localhost:80/CalculatorDemo; both are considered as exactly same.

    • 3.

      Path: This part is optional, but it can be the path of virtual directory while hosting the service on IIS. Multiple paths can be provided by using / operator.

Top

Type Of Address

There are three types of addresses available in WCF and each of these addresses are explained in the following section.

(A) Endpoint Address

It is the address of endpoint through which client and service can communicate. Once the client is connected to the service through one endpoint all the other communications between them is done through the same endpoint. The example of the endpoint is shown as:

  • http: //localhost/CalculatorDemo

Every service must have at least one endpoint with absolute address as shown above.

(B) Base Address

It is also known as primary address which works as base address for one or more endpoints. In the presence of a base address endpoint address can be relative. If the base address is not available endpoint address must be absolute. For instance, following is the base address:

  • http://localhost/Service

Suppose there are three endpoints having a relative address as below:

  • Endpoint 1: s1

  • Endpoint 2: s2

  • Endpoint 3: s3

Then the actual addresses of the endpoints are considered as:

  • Endpoint 1: http://localhost/Service/s1

  • Endpoint 2: http://localhost/Service/s2

  • Endpoint 3: http://localhost/Service/s3

The base address cannot be relative. If the endpoint address and base address both are absolute then both are not considered as same and not related with each other.

Complete Chapter List

Search this Book:
Reset