Section 1.3. Addresses


1.3. Addresses

In WCF, every service is associated with a unique address. The address provides two important elements: the location of the service and the transport protocol or transport schema used to communicate with 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.

WCF 1.0 supports the following transport schemas:

  • HTTP

  • TCP

  • Peer network

  • IPC (Inter-Process Communication over named pipes)

  • 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] 

Here are a few sample addresses:

 http://localhost:8001 http://localhost:8001/MyService net.tcp://localhost:8002/MyService net.pipe://localhost/MyPipe net.msmq://localhost/private/MyService net.msmq://localhost/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 

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."

1.3.1. TCP Addresses

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 808:

 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 

TCP-based addresses are used throughout this book.

You can configure TCP-based addresses from different hosts to share a port.


1.3.2. 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.

HTTP-based addresses are also used throughout this book.

1.3.3. IPC Addresses

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 

You can only open a named pipe once per machine, and therefore it is not possible for two named pipe addresses to share a pipe name on the same machine.

IPC-based addresses are used throughout this book.

1.3.4. 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 

Chapter 9 is dedicated to making queued calls.

1.3.5. 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.




Programming WCF Services
Programming WCF Services
ISBN: 0596526997
EAN: 2147483647
Year: 2004
Pages: 148
Authors: Juval Lowy

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net