TechEd - Windows Communication Foundation
WCF is a SDK for building SOA on Winodows. It is part of the Microsoft 3.0 Framework which ships with every Vista machine. It also requires the 2.0 Framework.
WCF is essentially Microsoft's next version of asmx pages and .Net Remoting, the difference being the service plumbing is totally abstracted from the developer and placed in the configuration file.
It can use the following transport methods.
- HTTP
- TCP
- P2P
- IPC
- MSMQ
The address is specified in the following syntax:
[transport]://[machine or domain][:port]
The programmer only has to assign some attributes to class he/she wants to expose and the framework does the rest. The developer would create an interface for the object they want to expose and the a concrete class which implements that interface.
For example:
[
[ServiceContract]
interface IMyContract
{
[OperationContract]
string MyMethod(string text);
//Will not be part of the contract
string MyOtherMethod(string text);
}
class MyService : IMyContract
{
public string MyMethod(string text)
{
return "Hello " + text;
}
public string MyOtherMethod(string text)
{
return "Cannot call this method over WCF";
}
}
The service must be hosted in a Windows process and a single host process can host more then once service. Once you select a host you then need to select a binding.
The binding is the mechanism for abstracting all of the piping out your code. In it you specify:
- Protocols
- Format and encoding
- Security
- Reliability
- Transportation propagation
- Interoperability
There is a great decision tree diagram of when to choose which type of binding which I will try and provide later.
Here is a sample of what your config file would look like:
binding = "wsHttpBinding"
contract = "MyNamespace.IMyContract"
/>
binding = "netTcpBinding"
contract = "MyNamespace.IMyContract"
/>
binding = "netTcpBinding"
contract = "MyNamespace.IMyOtherContract"
/>

0 Comments:
Post a Comment
<< Home