Every WCF service is associated with an address which will be used by the client to access the service. A WCF address provides two important elements,
- Location of the service
- Transport Protocol
Location service indicates that the name of the target machine, site or network; a communication port, pipe or queue and an optional specific path, or URI
Transport Protocol also called as Transport Schema is used to communicate with the service. Normally WCF supports below transport schemas
- HTTP or HTTPS
- TCP
- IPC
- Peer Network
- MSMQ
- Service Bus
Normally addresses have the below format,
[base address]/[optional port]
At the same time the base address has the format,
[transport]://[machine name or domain][:optional port]
HTTP addresses uses the http for transport and can also use HTTPS for secure transport. Typically uses http addresses with outward facing internet based services and we can specify a port also. If a specific port is not provided it will take the default port. For HTTP it is 80 and for HTTPS it would be 443. A sample http address is as follows,
TCP addresses uses net.tcp for transport and typically include a port number. If the port number is not provided the default for the tcp address is 808. A sample tcp address is as follows,
net.tcp://localhost:8002/MyService
IPC Addresses or 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. So we have to either provide the machine name or the localhost followed by a unique string for the pipe name. It is not possible for two named pipe addresses to share a pipe name on the same machine because we can open a named pipe only once per machine. A sample IPC address is as follows,
net.pipe://localhost/MyPipe
MSMQ or Microsoft Message Queue addresses use net.msmq for transport. We must specify the queue name. If the queue is private we must provide the queue type as well. Samples for the MSMQ is as follows,
net.msmq://localhost/private/MyService
net.msmq://localhost/MyService
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.
sb://MyNamespace.servicebus.windows.net/
Now you must have got an overall idea on different types of addresses used in WCF.
No comments:
Post a Comment