service. The binding used determines the security requirements for the communication and how clients will connect to the service.

□ Contract — The contract defines what the service offers. The following sections discuss each of these points in detail.

Addresses and Endpoints

Every WCF service has an address and endpoints in which it listens for incoming connections. Figure 20-18 shows a WCF service with two endpoints exposed. A client wanting to use the service just needs to send messages to the appropriate endpoint.

Figure 20-18

The address of a WCF service depends on the protocols used for the service. For example, if a WCF service uses the HTTP protocol, then its address may be:

□ http://<server>:<port>/<service>

□ https://<server>:<port>/<service>

□ https://<server>:<port>/<service>.svc

If a WCF service uses TCP as the protocol, its address is in this format:

net.tcp://<server>:<port>/<service>.

For Named Pipes, the address is net.pipe://<server>/<service>.

A service may have an operation that uses any of the protocols (or all). For example, a service may listen at port 80 (endpoint number 1) using HTTP as well as listen at port 5000 (endpoint number 2) using TCP.

Bindings

The bindings of a WCF not only specify the protocols used but also the security requirements for communication. The following table describes the available bindings:

Binding Description
BasicHttpBinding Most basic; limited security and no transactional support. Compatible with traditional ASMX Web Services.
WSHttpBinding More advanced HTTP with WSE security.
WSDualHttpBinding Extends WSHttpBinding and includes duplex communications.
WSFederationHttpBinding Extends WSHttpBinding and includes federation capabilities.
NetTcpBinding Used for TCP communication; supports security, transaction, and so on.
NetNamedPipeBinding Used for named pipe communication; supports security, transaction, and so on.
NetPeerTcpBinding Supports broadcast communication.
MexHttpBinding Publishes the metadata for the WCF service.
NetMsmqBinding Used for MSMQ.
MsmqIntegrationBinding Used for MSMQ.

The bindings of a WCF determine how a client can communicate with the service.

How to use BasicHttpBinding, WSHttpBinding, and NetTcpBinding bindings is shown later in this chapter.

Contracts

Contracts define what a WCF service offers. The types of available contracts are explained in the following table.

Contract Defines
Service All the operations contained in a service.
Operation All the methods, parameters, return types, and so on.
Message How messages are formatted. For instance, data should be included in SOAP header or SOAP message body, and so on.
Fault Faults an operation may return.
Вы читаете C# 2008 Programmer's Reference
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату