marți, 6 octombrie 2009

[WCF] Summaries III

First Part Here
Second Part Here

Addresses in WCF

- Addresses in WCF are URLs that define the protocol used, the machine where the service is running, and the path to the service
- So, the format of a service address is as follows:

Address Section Description
Transport scheme This defines the transport protocol (or scheme).
Machinename This specifies the fully qualified domain name of the machine.
Port The port is an optional field and is specified as :port. Port 80 is the default for HTTP addresses.
Path The path is the specific path to the service. You can define paths as names of directories separated by a forward slash. For example, /Stock/GetQuote is the path in the following address: http://localhost:8080/Stock/GetQuote.

In aWCF configuration, you can set the HTTP address as follows:
contract="IExchange" />

TCP transport uses the net.tcp: scheme.
Microsoft Message Queue (MSMQ) transport use the net.msmq scheme.
-> Port numbers don’t have any meaning in the MSMQ address.
-> net.msmq://localhost/private$/QuickReturnSettleTrade
Named Pipes : net.pipe://localhost/QuickReturns/Exchange

WCF supports base addresses, which enables you to host multiple endpoints under the same base address and which shortcuts the duplication of the scheme, host, port, and root path in your configuration.

contract="IExchange" />


What Are Bindings?
-> defines how you can communicate with the service?

The binding controls the following:
• The transport (HTTP, MSMQ, Named Pipes, TCP)
• The channels (one-way, duplex, request-reply)
• The encoding (XML, binary, MTOM…)
• The supported WS-* protocols (WS-Security, WS-Federation, WS-Reliability, WS-Transactions)

->you can have multiple endpoints defined for a service so that your service
supports any combination of these bindings
What Are Contracts?
-> One of the core principles of service orientation is explicit boundaries
-> The essence of contracts in service orientation is that you agree on what you expose to the outside
-> A contract is a declaration of exposed behavior
-> WCF service contracts can express three message exchange patterns that can be used in your:

  • Request-Reply (In WCF, request-reply is the default pattern)
  • One-Way (“fire-and-forget” style of messaging)
  • Duplex (a peer-to-peer connection, with both ends simultaneously acting as both a sender and a receiver)
The service contract is commonly referred to as the service interface or the exposed behavior of the service.

[ServiceContract] - service contracts
[OperationContract] - operations
[DataContract]->Data contracts control the mapping between SOAP messages and .NET objects.

See parameters here
[MessageContract] attribute allows you to map fields into either the SOAP body or the SOAP headers by means of the [MessageBody] and [MessageHeader] attributes.

WCF is a layered framework similar to the Open Systems Interactive (OSI) model

The messaging layer is the layer where the actual communication on the wire is happening.
The address expresses where the message should go, and the binding is the model you use to manipulate the message.
The binding is the mechanism to control the channel stack.
The channels are responsible for transferring a message.

Different Shapes of Channels

public interface IOutputChannel : IChannel {
void Send(Message message);
public interface IInputChannel : IChannel {
Message Receive();
public interface IDuplexChannel : IInputChannel, IOutputChannel { }
public interface IRequestChannel : IChannel {
Message Request(Message message);
public interface IReplyChannel : IChannel {
IRequestContext ReceiveRequest();
public interface IRequestContext : IDisposable {
Message RequestMessage { get; }
void Reply(Message message);

Channels come in three flavors:
• Transports
• Encoders
• Protocols

Niciun comentariu:

Trimiteți un comentariu