WCF Service is a program that exposes a collection of Endpoints. Each Endpoint is a portal for communicating with the world. All the WCF communications are take place through end point. End point consists of three components.
net.tcp://localhost:8001/Service
net.pipe://localhost/Service
net.msmq://localhost
Collection of operation that specifies what the endpoint will
communicate with outside world. Usually name of the Interface will be
mentioned in the Contract, so the client application will be aware of
the operations which are exposed to the client. Each operation is a
simple exchange pattern such as one-way, duplex and request/reply.
Below figure illustrate the functions of Endpoint
Endpoints will be mentioned in the web.config file on the created service.
Example :
Address
Basically URL, specifies where this WCF service is hosted .Client will use this url to connect to the service.
HTTP | It's a protocol for communication over the web (uses TCP at a lower level). |
TCP | High performance communication in WCF. Good for intranet scenarios. |
Named Pipe | Fast and reliable communication between client and server running on the same machine. |
MSMQ | Used when the client enqueues a message that a service can then consume later. |
e.g :
http://localhost:8090/MyService/SimpleCalculator.svcnet.tcp://localhost:8001/Service
net.pipe://localhost/Service
net.msmq://localhost
Binding
Binding will describes how client will communicate with service.
There are different protocols available for the WCF to communicate to
the Client. You can mention the protocol type based on your
requirements.
A binding has several characteristics, including the following:
A binding has several characteristics, including the following:
- Transport -Defines the base protocol to be used like HTTP, Named Pipes, TCP, and MSMQ are some type of protocols.
- Encoding (Optional) - Three types of encoding are available-Text, Binary, or Message Transmission Optimization Mechanism (MTOM). MTOM is an interoperable message format that allows the effective transmission of attachments or large messages (greater than 64K).
- Protocol(Optional) - Defines information to be used in the binding such as Security, transaction or reliable messaging capability
Binding | Description |
---|---|
BasicHttpBinding | Basic Web service communication. No security by default |
WSHttpBinding | Web services with WS-* support. Supports transactions |
WSDualHttpBinding | Web services with duplex contract and transaction support |
WSFederationHttpBinding | Web services with federated security. Supports transactions |
MsmqIntegrationBinding | Communication directly with MSMQ applications. Supports transactions |
NetMsmqBinding | Communication between WCF applications by using queuing. Supports transactions |
NetNamedPipeBinding | Communication between WCF applications on same computer. Supports duplex contracts and transactions |
NetPeerTcpBinding | Communication between computers across peer-to-peer services. Supports duplex contracts |
NetTcpBinding | Communication between WCF applications across computers. Supports duplex contracts and transactions |
Contract
Below figure illustrate the functions of Endpoint
Endpoints will be mentioned in the web.config file on the created service.
Example :
<system.serviceModel> <services> <service name="MathService" behaviorConfiguration="MathServiceBehavior"> <endpoint address="http://localhost:8090/MyService/MathService.svc" contract="IMathService" binding="wsHttpBinding"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="MathServiceBehavior"> <serviceMetadata httpGetEnabled="True"/> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>
No comments:
Post a Comment