Wednesday, August 8, 2012

WCF Endpoints : Addresses

All communication with a Windows Communication Foundation (WCF) service occurs through the endpoints of the service. Endpoints provide clients access to the functionality offered by a WCF service.
Each endpoint consists of four properties:
  • An address that indicates where the endpoint can be found.
  • A binding that specifies how a client can communicate with the endpoint.
  • A contract that identifies the operations available.
  • A set of behaviours that specify local implementation details of the endpoint.
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 scheme, 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 (Universal Resource Identifier). A URI can be any unique string, such as the service name or a globally unique identifier (GUID).
WCF supports the following transport schemes:
  • HTTP/HTTPS
  • TCP
  • IPC
  • Peer network
  • MSMQ
  • Service bus
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/MyQueue
    net.msmq://localhost/MyQueue


TCP Addresses
TCP addresses use net.tcp for transport and typically include a port number, as in:
    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) to share a port:
    net.tcp://localhost:8002/MyService
    net.tcp://localhost:8002/MyOtherService
You can configure TCP-based addresses from different service hosts to share a port.

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 you can specify a port as shown here:
    http://localhost:8001
If you do not specify the port number, it defaults to 80 (and port 443 for HTTPS). As with TCP addresses, two HTTP addresses from the same host can share a port, even on the same machine.

IPC Addresses
IPC (Inter-Process Communication) addresses use net.pipe for transport, to indicate the use of the Windows named pipe mechanism. In WCF, services that use IPC 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 open a named pipe only once per machine, so it is not possible for two named pipe addresses to share a pipe name on the same machine.

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 also specify the queue type, but you can omit that for public queues:
    net.msmq://localhost/private/MyService
    net.msmq://localhost/MyService

Service Bus Addresses
Windows Azure AppFabric Service Bus addresses use sb, http, or https for transport, and must include the service bus address along with the service namespace, for example:
    sb://MyNamespace.servicebus.windows.net/

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.