WCF

WCF Examples

WCF

WCF Projects

WCF Project

adplus-dvertising
WCF Addresses
Previous Home Next

WCF address provides two important elements:

  1. The location of the service: The location portion of the address indicates the name of the target machine, site, or network; a communication port, pipe, or queue; and an optional specific path or URI. A URI is a Universal Resource Identifier, and can be any unique string, such as the service name or a GUID.
  2. The transport protocol or transport schema used to communicate with the service.
WCF transport schemas:

WCF 1.0 supports the following transport schemas

  1. HTTP
  2. TCP
  3. )Peer network
  4. IPC (Inter-Process Communication over named pipes)
  5. MSMQ

Addresses always have the following format:

[base address]/[optional URI]

The base address is always in this format:

[transport]://[machine or domain][:optional port]

EXAMPLE:

  • http://localhost:8001
  • http://localhost:8001/MyService
  • net.tcp://localhost:8002/MyService
  • net.pipe://localhost/MyPipe
  • net.msmq://localhost/private/MyService

The way to read an address such as

http://localhost:8001 is like this: "Using HTTP, go to the machine called localhost, where on port 8001 someone is waiting for my calls.

If there is also a URI such as:

http://localhost:8001/MyService

http://localhost:8001/MyService

then the address would read as follows: "Using HTTP, go to the machine called localhost, where on port 8001 someone called

MyService is waiting for my calls."

HTTP Addresses:

HTTP addresses use http for transport, and can also use https for secure transport. You typically use HTTP addresses with outward-facing

Internet-based services, and can specify a port such as:

http://localhost:8001

When the port number is unspecified, it defaults to 80. Similar to TCP addresses, two HTTP addresses from the same host can share a port, even on the same machine.

TCP:

TCP addresses use net.tcp for the transport, and typically include a port number such as:

net.tcp://localhost:8002/MyService

When a port number is not specified, the TCP address defaults to port 8080:

net.tcp://localhost/MyService

It is possible for two TCP addresses (from the same host, which will be discussed more later on in this chapter) to share a port:

net.tcp://localhost:8002/MyService

net.tcp://localhost:8002/MyOtherService

IPC Addresses (Inter-Process Communication over named pipes)

IPC addresses use net.pipe for transport, to indicate the use of the Windows named pipe mechanism. In WCF, services that use named pipes can only accept calls from the same machine. Consequently, you must specify either the explicit local machine name or localhost for the machine name, followed by a unique string for the pipe name:

net.pipe://localhost/MyPipe

MSMQ Addresses:

MSMQ addresses use net.msmq for transport, to indicate the use of the Microsoft Message Queue (MSMQ). You must specify the queue name. When you're dealing with private queues, you must specify the queue type, but that can be omitted for public queues:

net.msmq://localhost/private/MyService

net.msmq://localhost/MyService

Peer Network Address:

Peer network addresses use net.p2p for transport, to indicate the use of the Windows peer network transport. You must specify the peer network name as well as a unique path and port. Using and configuring peer networks is beyond the scope of this book, and you will see very little mention of peer networks in subsequent chapters.

Previous Home Next