{"id":109,"date":"2013-08-20T14:35:33","date_gmt":"2013-08-20T14:35:33","guid":{"rendered":"https:\/\/praveenkatiyar.wordpress.com\/?p=109"},"modified":"2013-08-20T14:35:33","modified_gmt":"2013-08-20T14:35:33","slug":"introduction-to-wcf","status":"publish","type":"post","link":"https:\/\/praveenkatiyar.in\/blog\/index.php\/2013\/08\/20\/introduction-to-wcf\/","title":{"rendered":"Introduction to WCF"},"content":{"rendered":"<h3><font style=\"font-weight:bold;\">What is WCF<\/font><\/h3>\n<p><font color=\"#000080\" size=\"2\">In a nutshell, WCF is a <strong>SDK for developing and deploying<\/strong> <strong>services<\/strong> on Windows, although services can be build even without WCF.&#160; Developing services with WCF is easier. WCF is Microsoft\u2019s implementation of a set of industry standards defining service interactions, type conversions, marshaling, and management of various protocols. consequently, WCF provides interoperability between services.&#160;&#160;&#160;&#160; <\/font><\/p>\n<h3><font style=\"font-weight:bold;\">What is SOA<\/font><\/h3>\n<p><font color=\"#000080\" size=\"2\">SOA is the next evolutionary step in the long journey from <strong>functions<\/strong> to <strong>object<\/strong> to <strong>components<\/strong> to <strong>service orientated applications. <\/strong>Service orientation <strong>(SO) <\/strong>is an abstract set of methodologies, principles and best practices for building service oriented applications(SOA). Service oriented application aggregates services into a single logical application. <\/font><\/p>\n<h3><font style=\"font-weight:bold;\">What is a Service<\/font><\/h3>\n<p><font color=\"#000080\" size=\"2\">A service is a unit of functionality exposed to the world. the services can be local or remote, can be deployed by multiple parties using any technology. <\/font><\/p>\n<h3><font style=\"font-weight:bold;\">What is a WCF Service<\/font><\/h3>\n<p><font color=\"#000080\" size=\"2\">WCF Service typically exposes metadata describing the available functionality and possible ways of communicating with service. Metadata is published in a <strong>predefined, technology-neutral<\/strong> way such as using WSDL (Web Services Description Language) over HTTP-GET or an industry standard for metadata exchange over any protocol. WCF services may communicate over a variety of transports (not just HTTP). A non WCF client can import the metadata to its native environment as native types. similarly, a WCF client can import the metadata of a non WCF service and&#160; consume it as a native CLR class\/interface.&#160; <\/font><\/p>\n<h3><font style=\"font-weight:bold;\">Anatomy of WCF Service\/ <\/font><font color=\"#ff0000\"><font style=\"font-weight:bold;\">A<\/font><\/font><font style=\"font-weight:bold;\"> <\/font><font color=\"#008000\"><font style=\"font-weight:bold;\">B<\/font><\/font><font style=\"font-weight:bold;\"> <\/font><font color=\"#0000ff\"><font style=\"font-weight:bold;\">C<\/font><\/font><font style=\"font-weight:bold;\"> <\/font><font style=\"font-weight:bold;\">of WCF Service<\/font><\/h3>\n<h4><font color=\"#ff0000\">(A) Address<\/font><font color=\"#ff0000\"> <\/font><\/h4>\n<h3><font color=\"#000080\" size=\"2\">in WCF every service is associated with a unique address. the address provides two important elements: <\/font><\/h3>\n<ul>\n<li>\n<h3><font color=\"#000080\" size=\"2\"><font style=\"font-weight:bold;\">location of the service<\/font><font style=\"font-weight:bold;\">:<\/font>&#160;<\/font><font color=\"#000080\" size=\"2\"><font color=\"#000080\" size=\"2\">the location portion of the address indicates the name of the target machine, site, or network; a communication port, pipe or queue; and an optional specific path, or URI. URI can be any unique string, such as service name or a globally unique identifier (GUID).<\/font><\/font><\/h3>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<h3><font color=\"#000080\" size=\"2\"><font style=\"font-weight:bold;\">transport protocol\/transport scheme:<\/font> WCF supports following transport protocols\/schemes.<\/font><\/h3>\n<ul>\n<li>\n<h3><font color=\"#000080\" size=\"2\">HTTP\/HTTPS<\/font><\/h3>\n<\/li>\n<li>\n<h3><font color=\"#000080\" size=\"2\">TCP<\/font><\/h3>\n<\/li>\n<li>\n<h3><font color=\"#000080\" size=\"2\">IPC<\/font><\/h3>\n<\/li>\n<li>\n<h3><font color=\"#000080\" size=\"2\">Peer network<\/font><\/h3>\n<\/li>\n<li>\n<h3><font color=\"#000080\" size=\"2\">MSMQ<\/font><\/h3>\n<\/li>\n<li>\n<h3><font color=\"#000080\" size=\"2\">Service Bus<\/font><\/h3>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><font color=\"#000080\" size=\"2\">the address always have the following format<\/font><\/h3>\n<h3><font color=\"#000080\" size=\"2\"><font color=\"#000080\">[<font style=\"font-weight:bold;\">base address<\/font>] \/ [<font style=\"font-weight:bold;\" color=\"#f3a447\">optional URI<\/font>]<\/font> <\/font><\/h3>\n<h3><font color=\"#000080\" size=\"2\">the base address is always in the format <\/font><\/h3>\n<h3><font color=\"#000080\" size=\"2\"><font style=\"font-weight:bold;\" color=\"#c0504d\"><font color=\"#000080\">[<\/font>transport<font color=\"#000080\">]<\/font><\/font><font color=\"#000080\">:\/\/<\/font><font style=\"font-weight:bold;\" color=\"#9b00d3\"><font color=\"#000080\">[<\/font>machine or domain<font color=\"#000080\">]<\/font><\/font><font style=\"font-weight:bold;\" color=\"#4f81bd\"><font color=\"#000080\">[<\/font>optional port<font color=\"#000080\">]<\/font><\/font><\/font><\/h3>\n<p><font color=\"#000080\" size=\"2\">here are few examples of&#160; sample addresses.<\/font><\/p>\n<blockquote>\n<p><font color=\"#000080\" size=\"2\"><strong><font color=\"#c0504d\">http<\/font>:\/\/<font color=\"#9b00d3\">localhost<\/font>:<\/strong><font color=\"#4f81bd\"><strong>8001<\/strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/p>\n<\/blockquote>\n<blockquote>\n<p><font color=\"#000080\" size=\"2\"><strong><font color=\"#c0504d\">http<\/font>:\/\/<font color=\"#9b00d3\">localhost<\/font>:<\/strong><font color=\"#4f81bd\"><strong>8001\/<font color=\"#f3a447\">MyService<\/font><\/strong><font color=\"#008000\"><font color=\"#f3a447\">&#160;&#160; <\/font>&#160;<\/font>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/p>\n<\/blockquote>\n<blockquote>\n<p><font color=\"#000080\" size=\"2\"><strong><font color=\"#c0504d\">net.tcp<\/font>:\/\/<font color=\"#9b00d3\">localhost<\/font>:<\/strong><font color=\"#4f81bd\"><strong>8002\/<font color=\"#f3a447\">MyService<\/font><\/strong><font color=\"#f3a447\">&#160;&#160;&#160;&#160; <\/font>&#160; <\/font><\/font><\/p>\n<\/blockquote>\n<blockquote>\n<p><font size=\"2\"><strong><font color=\"#c0504d\">net.pipe<\/font>:\/\/<font color=\"#9b00d3\">localhost<\/font><\/strong><font color=\"#4f81bd\"><strong><font color=\"#000000\">\/<\/font><font color=\"#f3a447\">MyPipe<\/font><\/strong><font color=\"#f3a447\">&#160;&#160; <\/font>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/p>\n<\/blockquote>\n<blockquote>\n<p><font size=\"2\"><strong><font color=\"#c0504d\">net.msmq<\/font>:\/\/<font color=\"#9b00d3\">localhost<\/font><\/strong><font color=\"#4f81bd\"><strong><font color=\"#000000\">\/<\/font><font color=\"#f3a447\">MyQueue<\/font><\/strong><font color=\"#f3a447\">&#160;&#160; <\/font>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/font><\/font><\/p>\n<\/blockquote>\n<p><font color=\"#000080\" size=\"2\">here are few examples of&#160; sample addresses.<\/font><\/p>\n<h4><font color=\"#008000\">(B) Binding<\/font><\/h4>\n<h3><font color=\"#000080\" size=\"2\">A binding is merely, a consistent, canned set of choices regarding the transport protocol, message encoding, communication pattern, reliability, security, transaction propagation and interoperability. A single service can support multiple bindings on separate addresses. Binding allow you to use the same service logic over drastically different plumbing. all you need to do is determine the target scenario for your service, and WCF makes a correct multidimensional decision for you regarding all the aspects of the communication. One can use the WCF-provided bindings out of the box, can tweak their properties, or can write their own custom bindings from scratch. WCF defines <font style=\"font-weight:bold;\">5 frequently used bindings<\/font>.<\/font><\/h3>\n<ul>\n<li><font color=\"#000080\"><strong>Basic Binding: <\/strong>offered by the <strong>BasicHttpBinding<\/strong> class, basic binding is designed to expose a WCF services as a legacy ASMX web service, so that old clients can work with the new services. this binding makes your service look like a legacy web service that communicates over basic web service profile. when used by clients, this enables new WCF clients to work with old ASMX services.<\/font> <\/li>\n<li><font color=\"#000080\"><strong>TCP Binding:<\/strong>&#160; offered by <strong>NetTcpBinding<\/strong> class, TCP binding uses TCP for cross machine communication on the intranet. it supports variety of features, including reliability, transactions and security, and is <strong>optimized for WCF to WCF<\/strong> communication, hence it <strong>requires both the client and the service to use WCF<\/strong>.<\/font> <\/li>\n<li><font color=\"#000080\"><strong>IPC Binding:<\/strong> offered by <strong>NetNamedPipeBinding<\/strong> class, IPC binding uses named pipes as a transport for same-machine communication. <strong>it is the most secure binding<\/strong>, since it can not accept calls outside of the machine boundary. It is also the most performant binding, since IPC is a lighter protocol than TCP.<\/font> <\/li>\n<li><font color=\"#000080\"><strong>Web Service (WS) Binding:<\/strong> offered by <strong>WSHttpBinding <\/strong>class, the WS binding uses HTTP or HTTPS for transport and offers a variety of features(such as reliability, transactions, and security) over the <strong>Internet<\/strong>, all using the WS-* standards.<\/font> <\/li>\n<li><font color=\"#000080\"><strong>MSMQ Binding: <\/strong>offered by the <strong>NetMsmqBinding<\/strong> class, the MSMQ binding uses MSMQ for transport and offers support for disconnected queued calls.&#160; <\/font><\/li>\n<\/ul>\n<p><font color=\"#000080\">each frequently used binding&#160; uses different transport scheme and encoding as shown below.<\/font><\/p>\n<table cellspacing=\"0\" cellpadding=\"2\" width=\"494\" border=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"195\"><strong><font color=\"#000080\" size=\"3\">Name<\/font><\/strong><\/td>\n<td valign=\"top\" width=\"124\"><strong><font color=\"#000080\" size=\"3\">Transport<\/font><\/strong><\/td>\n<td valign=\"top\" width=\"90\"><strong><font color=\"#000080\" size=\"3\">Encoding<\/font><\/strong><\/td>\n<td valign=\"top\" width=\"83\"><strong><font color=\"#000080\" size=\"3\">Interoperable<\/font><\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"195\"><font color=\"#000080\" size=\"2\">BasicHttpBdinding <\/font><\/td>\n<td valign=\"top\" width=\"124\"><font color=\"#000080\" size=\"2\">HTPP\/HTTPS<\/font><\/td>\n<td valign=\"top\" width=\"90\"><font color=\"#0000ff\" size=\"2\"><strong>TEXT, MTOM<\/strong><\/font><\/td>\n<td valign=\"top\" width=\"83\"><font color=\"#0000ff\" size=\"2\"><strong>Yes<\/strong><\/font><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"195\"><font color=\"#000080\" size=\"2\">NetTcpBinding<\/font><\/td>\n<td valign=\"top\" width=\"124\"><font color=\"#000080\" size=\"2\">TCP<\/font><\/td>\n<td valign=\"top\" width=\"90\"><font color=\"#c0504d\" size=\"2\"><strong>Binary<\/strong><\/font><\/td>\n<td valign=\"top\" width=\"83\"><font color=\"#c0504d\" size=\"2\"><strong>No<\/strong><\/font><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"195\"><font color=\"#000080\" size=\"2\">NetNamedPipeBinding <\/font><\/td>\n<td valign=\"top\" width=\"124\"><font color=\"#000080\" size=\"2\">IPC<\/font><\/td>\n<td valign=\"top\" width=\"90\"><font color=\"#c0504d\" size=\"2\"><strong>Binary<\/strong><\/font><\/td>\n<td valign=\"top\" width=\"83\"><font color=\"#c0504d\" size=\"2\"><strong>No<\/strong><\/font><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"195\"><font color=\"#000080\" size=\"2\">WsHttpBinding<\/font><\/td>\n<td valign=\"top\" width=\"124\"><font color=\"#000080\" size=\"2\">HTTP\/HTTPS<\/font><\/td>\n<td valign=\"top\" width=\"90\"><font color=\"#0000ff\" size=\"2\"><strong>TEXT, MTOM<\/strong><\/font><\/td>\n<td valign=\"top\" width=\"83\"><font color=\"#0000ff\" size=\"2\"><strong>Yes<\/strong><\/font><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"195\"><font color=\"#000080\" size=\"2\">NetMsmqBidning<\/font><\/td>\n<td valign=\"top\" width=\"124\"><font color=\"#000080\" size=\"2\">MSMQ<\/font><\/td>\n<td valign=\"top\" width=\"90\"><font color=\"#c0504d\" size=\"2\"><strong>Binary<\/strong><\/font><\/td>\n<td valign=\"top\" width=\"83\"><font color=\"#c0504d\" size=\"2\"><strong>No<\/strong><\/font><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><font color=\"#000080\">having text based encoding typically enables a WCF service (or client) to communicate over HTTP with any other service (or client), regardless of its technology and across firewalls. Binary encoding over TCP, IPC or MSMQ yields the best performance, but it does so at the cost of interoperability because it mandates the WCF-WCF communication.<\/font><\/p>\n<h5><font color=\"#333333\">Choosing a Binding<\/font><\/h5>\n<p><font color=\"#000080\">When choosing a binding the following diagram can help.<\/font><\/p>\n<p><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/08\/image5.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;float:none;padding-top:0;padding-left:0;margin-left:auto;display:block;padding-right:0;margin-right:auto;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/08\/image_thumb5.png\" width=\"519\" height=\"254\" \/><\/a><\/p>\n<p><font color=\"#000080\">in addition to the five frequently used bindings described above, WCF defines 6 infrequently used bindings. these bindings are each designed for a specific target scenario, which normally can not be used out of that scenario.&#160; <\/font><\/p>\n<ul>\n<li><font color=\"#000080\"><strong>WS dual binding:<\/strong>&#160; offered by <strong>WSDualHttpBinding<\/strong> class, similar to the WS binding, except it also supports bidirectional duplex communication from the service to the client. This binding nothing more than <strong>just two WsHttpBinding bindings wired up against each other to support callbacks<\/strong>, as there is no industry standard for setting up callback, thus <strong>WSDualHttpBinding is not interoperable<\/strong>.<\/font> <\/li>\n<li><font color=\"#000080\"><strong>Peer Network binding:<\/strong> offered by <strong>NetPeerTcpBinding<\/strong> class, this uses peer networking as a transport: the peer network enabled client and services all subscribe to the same grid and broadcast messages to it.<\/font> <\/li>\n<li><font color=\"#000080\"><strong>Fedrated WS binding<\/strong>: offered by <strong>WSFedrationHttpBinding<\/strong> class, a specialization of WS binding that offers support for federated security, not a main stream binding.<\/font>&#160; <\/li>\n<li><font color=\"#000080\"><strong>Fedrated WS 2007 binding<\/strong>: offered by <strong>WS2007FedrationHttpBinding<\/strong> class, this is an update of a WSFedrationHttpBinding. <\/font><\/li>\n<li><font color=\"#000080\"><strong>MSMQ integration binding:<\/strong> offered by <strong>MSMQIntegrationBinding<\/strong> class, this is the analogous queued \u2013world binding to the basic binding. The integration binding converts WCF messages to and from MSMQ messages and is designed to interoperate with legacy MSMQ clients.<\/font> <\/li>\n<li><font color=\"#000080\"><font color=\"#000080\"><strong>WS 2007 binding<\/strong>: offered by <strong>WS2007HttpBinding<\/strong> class, this binding is <strong>derived from the WSHttpBinding<\/strong> class; it adds support for the emerging co-ordination standard and updates for the transaction, security, and reliability standards.<\/font><\/font> <\/li>\n<\/ul>\n<h4><font color=\"#0000ff\">(C) Contracts<\/font><\/h4>\n<p><font color=\"#000080\">A WCF contract is a platform neutral and standard way of describing what a service does. in WCF all services expose contracts. WCF defines 4 types of contracts.<\/font><\/p>\n<ul>\n<li><font color=\"#000080\" size=\"2\"><strong>Service Contracts: <\/strong>Describes which related operations can be tied together as a single functional unit that the client can perform on the service. Service contracts can be defined as shown below.<\/font>\n<p><font color=\"#0000ff\"><font size=\"2\"><font face=\"Verdana\"><strong>[ServiceContract]                <br \/><\/strong>public interface IMyService               <br \/>{<\/font><\/font><\/font><\/p>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Verdana\">}<\/font><\/p>\n<\/li>\n<li><font color=\"#000080\" size=\"2\"><strong>Operation Contract: <\/strong>An operation contract defines the parameters and return type of an operation.<\/font>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Verdana\">[ServiceContract]          <br \/>public interface IMyService           <br \/>{           <br \/>&#160;&#160; <strong>[OperationContract]            <br \/><\/strong>&#160;&#160;&#160; double MultiplyNumber(double dblX, double dblY );&#160;&#160;&#160; <br \/>&#160;&#160; <strong>[OperationContract]            <br \/><\/strong>&#160;&#160;&#160; double DivideNumber(double dblX, double dblY );&#160;&#160; <br \/>}<\/font><\/p>\n<\/li>\n<\/ul>\n<ul>\n<li><font color=\"#000080\" size=\"2\"><strong>Data Contracts: <\/strong>Defines which data types are passed to and from the service. WCF defines implicit contracts for built in types such as <strong>int <\/strong>and <strong>string<\/strong>, but you can easily define explicit opt in data contracts for custom types. <\/font>\n<p><font size=\"2\" face=\"Verdana\"><font color=\"#0000ff\"><strong>[DataContract]              <br \/><\/strong>public class ErrorInfo             <br \/>{             <br \/>&#160;&#160;&#160; private string m_strError;             <br \/>&#160;&#160;&#160; private int m_nErrorCode;             <br \/>&#160;&#160;&#160; <br \/>&#160;&#160; <strong>[DataMember]              <br \/><\/strong>&#160;&#160;&#160; public string ErrorMessage             <br \/>&#160;&#160;&#160; {             <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; get { return m_strError; }             <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; set { m_strError = value; }             <br \/>&#160;&#160;&#160; }<\/font><\/font><\/p>\n<p><font color=\"#0000ff\"><font size=\"2\" face=\"Verdana\">&#160;&#160; <strong>[DataMember]              <br \/><\/strong>&#160;&#160;&#160; public int ErrorCode             <br \/>&#160;&#160;&#160; {             <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; get { return m_nErrorCode }             <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; set { m_nErrorCode = value; }             <br \/>&#160;&#160;&#160; }             <br \/>}<\/font>           <br \/><\/font><\/p>\n<\/li>\n<\/ul>\n<ul>\n<li><font color=\"#000080\" size=\"2\"><strong>Fault Contracts: <\/strong>Defines which errors are raised by the service and how the service handles and propagates errors to the clients. Fault Contract provides documented view for error occurred in the service to client. This helps to easily identity the error.<\/font>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Verdana\">[ServiceContract]          <br \/>public interface IMyService           <br \/>{           <br \/>&#160;&#160;&#160; [OperationContract]           <br \/>&#160;&#160;&#160; double MultiplyNumber(double dblX, double dblY );&#160;&#160;&#160; <br \/>&#160;&#160;&#160; [OperationContract]           <br \/>&#160;&#160; <strong>[FaultContract(typeof(DevideByZeroException))]            <br \/><\/strong>&#160;&#160;&#160; double DivideNumber(double dblX, double dblY );&#160;&#160; <br \/>}<\/font><\/p>\n<\/li>\n<\/ul>\n<ul>\n<li><font color=\"#000080\" size=\"2\"><strong>Message Contracts:<\/strong> Allow the service to interact directly with messages. Message contracts can be types or un typed and are useful in interoperability cases when another party has already dictated some explicit (mostly proprietary) message format.&#160; <\/font>\n<p><font color=\"#0000ff\" face=\"Verdana\"><font size=\"2\"><strong>[MessageContract]<\/strong>             <br \/>public class ErrorDetails             <br \/>{             <br \/>&#160; <strong>&#160; [MessageHeader]              <br \/><\/strong>&#160;&#160;&#160; public int&#160; ErrorCode;             <br \/>&#160;&#160;&#160; <br \/>&#160;&#160; <strong>[MessageBodyMember]              <br \/><\/strong>&#160;&#160;&#160; public string ErrorMessage;             <br \/>&#160;&#160; <strong>[MessageBodyMember]              <br \/><\/strong>&#160;&#160;&#160; public DateTime ErrorTime;             <br \/>}<\/font><\/font><\/p>\n<\/li>\n<\/ul>\n<h3><font style=\"font-weight:bold;\">Hosting<\/font> <\/h3>\n<p><font color=\"#000080\">The WCF service class can not exist in void. every WCF service must be hosted in a Windows process called host process. a single host process can host multiple services, and the same service type can be hosted in multiple services.<\/font><\/p>\n<h4>Hosting Environment and Supported Bindings<\/h4>\n<table cellpadding=\"0\" border=\"1\">\n<tbody>\n<tr>\n<td width=\"59%\">\n<p><b><font color=\"#000080\" size=\"2\">Hosting Environment<\/font><\/b><\/p>\n<\/td>\n<td width=\"39%\">\n<p><b><font color=\"#000080\" size=\"2\">Supported protocol<\/font><\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"59%\">\n<p><font color=\"#000080\">Windows console and form application<\/font><\/p>\n<\/td>\n<td width=\"39%\">\n<p><font color=\"#000080\">http, net.tcp, net.pipe, net.msmq<\/font><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"59%\">\n<p><font color=\"#000080\">Windows service application (formerly known as NT services)<\/font><\/p>\n<\/td>\n<td width=\"39%\">\n<p><font color=\"#000080\">http, net.tcp, net.pipe, net.msmq<\/font><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"59%\">\n<p><font color=\"#000080\">Web server IIS6<\/font><\/p>\n<\/td>\n<td width=\"39%\">\n<p><font color=\"#000080\">http, wshttp<\/font><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"59%\">\n<p><font color=\"#000080\">Web server IIS7 &#8211; Windows Process Activation Service (WAS)<\/font><\/p>\n<\/td>\n<td width=\"39%\">\n<p><font color=\"#000080\">http, net.tcp, net.pipe, net.msmq<\/font><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>&#160;<\/h4>\n<h4>A <b>summary of hosting options and supported features. <\/b><\/h4>\n<p><b><\/b>    <\/p>\n<table cellpadding=\"0\" width=\"594\" border=\"1\">\n<tbody>\n<tr>\n<td width=\"225\">\n<p><b><font color=\"#000080\" size=\"2\">Feature<\/font><\/b><\/p>\n<\/td>\n<td width=\"131\">\n<p><b><font color=\"#000080\" size=\"2\">Self-Hosting<\/font><\/b><\/p>\n<\/td>\n<td width=\"111\">\n<p><b><font color=\"#000080\" size=\"2\">IIS Hosting<\/font><\/b><\/p>\n<\/td>\n<td width=\"125\">\n<p><b><font color=\"#000080\" size=\"2\">WAS Hosting<\/font><\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"225\">\n<p><font color=\"#000080\">Executable Process\/ App Domain<\/font><\/p>\n<\/td>\n<td width=\"131\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<td width=\"111\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<td width=\"125\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"225\">\n<p><font color=\"#000080\">Configuration<\/font><\/p>\n<\/td>\n<td width=\"131\">\n<p><font color=\"#000080\">App.config<\/font><\/p>\n<\/td>\n<td width=\"111\">\n<p><font color=\"#000080\">Web.config<\/font><\/p>\n<\/td>\n<td width=\"125\">\n<p><font color=\"#000080\">Web.config<\/font><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"225\">\n<p><font color=\"#000080\">Activation<\/font><\/p>\n<\/td>\n<td width=\"131\">\n<p><font color=\"#000080\">Manual at startup<\/font><\/p>\n<\/td>\n<td width=\"111\">\n<p><font color=\"#000080\">Message-based<\/font><\/p>\n<\/td>\n<td width=\"125\">\n<p><font color=\"#000080\">Message-based<\/font><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"225\">\n<p><font color=\"#000080\">Idle-Time Management<\/font><\/p>\n<\/td>\n<td width=\"131\">\n<p><font color=\"#000080\">No<\/font><\/p>\n<\/td>\n<td width=\"111\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<td width=\"125\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"225\">\n<p><font color=\"#000080\">Health Monitoring<\/font><\/p>\n<\/td>\n<td width=\"131\">\n<p><font color=\"#000080\">No<\/font><\/p>\n<\/td>\n<td width=\"111\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<td width=\"125\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"225\">\n<p><font color=\"#000080\">Process Recycling<\/font><\/p>\n<\/td>\n<td width=\"131\">\n<p><font color=\"#000080\">No<\/font><\/p>\n<\/td>\n<td width=\"111\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<td width=\"125\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"225\">\n<p><font color=\"#000080\">Management Tools<\/font><\/p>\n<\/td>\n<td width=\"131\">\n<p><font color=\"#000080\">No<\/font><\/p>\n<\/td>\n<td width=\"111\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<td width=\"125\">\n<p><font color=\"#000080\">Yes<\/font><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><font style=\"font-weight:bold;\">Endpoints<\/font><\/h3>\n<p><font color=\"#000080\">Every service is associated with an <strong>address that defines where the service is<\/strong>, a <strong>binding defines how to communicate<\/strong> with the service, and the <strong>contract defines what the service does<\/strong>. WCF formalizes this relationship in the form of endpoint. The endpoint is the coalition of address, binding and contract. So every endpoint must have all 3 elements, and the host exposes the endpoint. logically, endpoint is the interface of the service to the outside world. Every service must expose at least one business Endpoint, and each endpoint has exactly one contract. All endpoints on a service has unique addresses, and a single service can expose multiple endpoints. <\/font><\/p>\n<h4>Configuration of Endpoint<\/h4>\n<p><font color=\"#000080\">It is important to note <strong>nothing in the service code has to do with its service points<\/strong>. and they are always external to the service code. you can configure endpoints either administratively or programmatically.<\/font><\/p>\n<h5>Administrative Endpoint Configuration<\/h5>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Vrinda\"><strong>&lt;system.ServiceModel&gt;        <br \/>&#160;&#160;&#160; &lt;services&gt;         <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;service name=&quot;MyService&quot;&gt;         <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;endpoint address=&quot;http:\/\/localhost:8000\/MyService&quot; binding =&quot;wsHttpBinding&quot; contract=&quot;IMyContract&quot;&gt;         <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;endpoint address=&quot;http:\/\/localhost:8001\/MyService&quot; binding =&quot;netTcpBinding&quot; contract=&quot;IMyContract&quot;&gt;         <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;endpoint address=&quot;http:\/\/localhost:8002\/MyService&quot; binding =&quot;netTcpBinding&quot; contract=&quot;IOtherContract&quot;&gt;         <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;\/service&gt;         <br \/>&#160;&#160;&#160; &lt;\/services&gt;         <br \/>&lt;\/system.ServiceModel&gt;<\/strong><\/font><\/p>\n<h5>Programmatic Endpoint Configuration<\/h5>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Vrinda\"><strong>ServiceHost host = new ServiceHost(typeof(MyService));        <br \/>Binding httpBinding = new WSHttpBinding();         <br \/>Binding tcpBinding = new NetTcpBinding();         <br \/>host.AddServiceEndPoint( typeof (IMyContract), httpBinding, &quot;<\/strong><\/font><a href=\"http:\/\/localhost:8000\/MyService&quot;);\"><font color=\"#0000ff\" size=\"2\" face=\"Vrinda\">http:\/\/localhost:8000\/MyService&quot;);<\/font><\/a>     <br \/><font color=\"#0000ff\" size=\"2\" face=\"Vrinda\"><strong>host.AddServiceEndPoint( typeof (IMyContract), tcpBinding, &quot;net.tcp:\/\/localhost:8001\/MyService&quot;);        <br \/>host.AddServiceEndPoint( typeof (IMyOtherContract), tcpBinding, &quot;net.tcp:\/\/localhost:8002\/MyService&quot;);<\/strong><\/font><\/p>\n<p><strong><font color=\"#0000ff\" size=\"2\" face=\"Vrinda\"><\/font><\/strong><\/p>\n<h4>Default Endpoints<\/h4>\n<p><font color=\"#000080\">If the service host does not define any end points (neither in configuration nor programmatically) but does provide at least one base address. WCF will by default add endpoints to the service. These are called default endpoints. WCF will add an endpoint per base address per contract, using the base address as the endpoint\u2019s address. for HTTP WCF will use the basic binding. Note that default binding will affect the default endpoints. WCF will also name the endpoint by concatenating the binding name and the contract name.<\/font><\/p>\n<p><font color=\"#000080\">consider the following example.<\/font><\/p>\n<p><strong><font color=\"#000080\">[ServiceContract]        <br \/>interface IMyContract {         <br \/>&#160;&#160;&#160; \/\/Interface Body         <br \/>&#160;&#160;&#160; &#8230;&#160; <br \/>}<\/font><\/strong><\/p>\n<p><strong><font color=\"#008000\">[ServiceContract]        <br \/>interface IMyOtherContract {         <br \/>&#160;&#160;&#160; \/\/Interface Body         <br \/>&#160;&#160;&#160; &#8230;&#160; <br \/>}<\/font><\/strong><\/p>\n<p><font color=\"#000080\">class MyService : IMyContract, <font color=\"#000080\">IMyOtherContract<\/font> {       <br \/>&#160;&#160;&#160; \/\/Class Body       <br \/>&#160;&#160;&#160; &#8230;&#160; <br \/>}<\/font><\/p>\n<p><font color=\"#0000ff\" size=\"2\"><font color=\"#000080\">\/\/&#160;&#160;&#160; Host Application<\/font>       <br \/>Uri <font color=\"#0000ff\">httpbaseAdr<\/font> = new Uri ( &quot;<font color=\"#ff0000\"><strong>http:\/\/<\/strong><\/font>localhost:8000\/&quot;);       <br \/>Uri tcpbaseAdr = new Uri ( &quot;<font color=\"#c0504d\"><strong>net.tcp:\/\/<\/strong><\/font>localhost:9000\/&quot;);       <br \/>Uri pipebaseAdr = new Uri ( &quot;<strong><font color=\"#000000\">net.pipe:\/\/<\/font><\/strong>localhost\/&quot;);       <br \/>ServiceHost host = new ServiceHost ( typeof (MyService), httpbaseAdr, tcpbaseAdr, pipebaseAdr);       <br \/>host.Open ();<\/font><\/p>\n<p><font color=\"#0000ff\" size=\"1\">Assuming that no config file is used to define any additional endpoints, WCF will add these default endpoints, as they were defined in config file. <\/font><\/p>\n<p><font color=\"#0000ff\" size=\"1\"><font size=\"2\"><strong>&lt;service name=&quot;MyService&quot;&gt;<\/strong><\/font><\/font><\/p>\n<p><font color=\"#0000ff\" size=\"1\"><font size=\"2\">       <br \/>&#160;&#160;&#160; &lt;endpoint name=&quot;BasicHttpBinding_IMyContract&quot; address=&quot;<font color=\"#ff0000\"><strong>http:\/\/localhost:8000\/<\/strong><\/font>&quot; binding=&quot;<font color=\"#ff0000\"><strong>basicHttpBinding<\/strong><\/font>&quot; contract=&quot;<strong><font color=\"#0000a0\">IMyContract<\/font><\/strong>&quot; \/&gt;         <br \/>&#160;&#160;&#160; &lt;endpoint name=&quot;NetTcpBinding_IMyContract&quot; address=&quot;<font color=\"#c0504d\"><strong>net.tcp:\/\/localhost:9000\/<\/strong><\/font>&quot; binding=&quot;<font color=\"#c0504d\"><strong>netTcpBinding<\/strong><\/font>&quot; contract=&quot;<strong><font color=\"#0000a0\">IMyContract<\/font><\/strong>&quot; \/&gt;         <br \/>&#160;&#160;&#160; &lt;endpoint name=&quot;NetNamedPipeBinding_IMyContract&quot; address=&quot;<strong><font color=\"#000000\">net.pipe:\/\/localhost\/<\/font><\/strong>&quot; binding=&quot;<font color=\"#000000\"><strong>netNamedPipeBinding<\/strong><\/font>&quot; contract=&quot;<strong><font color=\"#000080\">IMyContract<\/font><\/strong>&quot; \/&gt;         <br \/><\/font>&#160;&#160;&#160; <br \/><font size=\"2\">&#160;&#160;&#160; &lt;endpoint name=&quot;BasicHttpBinding_IMyOtherContract&quot; address=&quot;<font color=\"#ff0000\"><strong>http:\/\/localhost:8000\/<\/strong><\/font>&quot; binding=&quot;<font color=\"#ff0000\"><strong>basicHttpBinding<\/strong><\/font>&quot; contract=&quot;<strong><font color=\"#008000\">IMyOtherContract<\/font><\/strong>&quot; \/&gt;         <br \/>&#160;&#160;&#160; &lt;endpoint name=&quot;NetTcpBinding_IMyOtherContract&quot; address=&quot;<strong><font color=\"#c0504d\">net.tcp:\/\/localhost:9000\/<\/font><\/strong>&quot; binding=&quot;<font color=\"#c0504d\"><strong>netTcpBinding<\/strong><\/font>&quot; contract=&quot;<strong><font color=\"#008000\">IMyOtherContract<\/font><\/strong>&quot; \/&gt;         <br \/>&#160;&#160;&#160; &lt;endpoint name=&quot;NetNamedPipeBinding_IMyOtherContract&quot; address=&quot;<strong><font color=\"#000000\">net.pipe:\/\/localhost\/<\/font><\/strong>&quot; binding=&quot;<strong><font color=\"#000000\">netNamedPipeBinding<\/font><\/strong>&quot; contract=&quot;<strong><font color=\"#008000\">IMyOtherContract<\/font><\/strong>&quot; \/&gt;         <br \/><\/font><\/font><\/p>\n<p><font color=\"#0000ff\" size=\"2\"><strong>&lt;\/service&gt;<\/strong>&#160;&#160;&#160; <\/font><\/p>\n<h3><font style=\"font-weight:bold;\">Metadata Exchange<\/font><\/h3>\n<p><font color=\"#000080\">By default, the service will not publish its metadata. publishing you service meta data will need some efforts. , luckily, the host can do it for you, if you instruct it to do so, as host knows everything, it needs to know about your service and its endpoints.<\/font><\/p>\n<p><font color=\"#000080\">Enabling Metadata exchange administratively<\/font><\/p>\n<p><font color=\"#000080\"><font size=\"2\">&lt;system.ServiceModel&gt;        <br \/>&lt;services&gt;         <br \/>&#160;&#160;&#160; &lt;service name=&quot;MyService&quot; behaviorConfiguration=&quot;<strong>MEXGET<\/strong>&quot;&gt;         <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;host&gt;         <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;baseAddresses&gt;         <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;add baseAddress = &quot;net.pipe:\/\/localhost\/&quot; \/&gt;&#160; <br \/><\/font><\/font><font color=\"#000080\" size=\"2\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;\/baseAddresses&gt;      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;endpoint <font color=\"#ff0000\"><strong>address<\/strong><\/font>=&quot;<strong>MEX<\/strong>&quot; <font color=\"#008000\"><strong>binding<\/strong><\/font>=&quot;<strong>mexNamedPipeBinding<\/strong>&quot; <font color=\"#0000ff\"><strong>contract<\/strong><\/font>=&quot;IMetadataExchange&quot;\/&gt;<\/font><\/p>\n<p><font color=\"#000080\" size=\"2\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#000000\"><strong>&lt;!&#8211; Here we have defined the complete address, we do not use the base address. -\u2013&gt;          <br \/><\/strong><\/font>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;endpoint <font color=\"#ff0000\"><strong>address<\/strong><\/font>=&quot;<font size=\"2\">http:\/\/localhost:8000\/<\/font><strong>MEX<\/strong>&quot; <font color=\"#008000\"><strong>binding<\/strong><\/font>=&quot;<strong>mexHttpBinding<\/strong>&quot; <font color=\"#0000ff\"><strong>contract<\/strong><\/font>=&quot;IMetadataExchange&quot;\/&gt;<\/font><\/p>\n<p><font color=\"#000080\" size=\"2\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;endpoint <font color=\"#ff0000\"><strong>address<\/strong><\/font>=&quot;net.tcp:\/\/localhost:8001\/<strong>MEX<\/strong>&quot; <font color=\"#008000\"><strong>binding<\/strong><\/font>=&quot;<strong>mexTcpBinding<\/strong>&quot; <font color=\"#0000ff\"><strong>contract<\/strong><\/font>=&quot;IMetadataExchange&quot;\/&gt;       <\/p>\n<p>&#160;&#160;&#160; &lt;\/service&gt;&#160;&#160;&#160; <br \/>&lt;\/services&gt;       <br \/>&lt;\/system.ServiceModel&gt;<\/font><\/p>\n<p><font color=\"#000080\">in the vast majority of cases, a <strong>MEX endpoint always has the same 3 elements:<\/strong> the <font color=\"#0000ff\"><strong>contract <\/strong><\/font>is always <strong>IMetadataExchange<\/strong>, the binding is always the reserved <font color=\"#008000\"><strong>binding<\/strong><\/font> element, and the only variable is the <font color=\"#ff0000\"><strong>address<\/strong><\/font> (and that too, just the base address)<\/font><\/p>\n<h3><font style=\"font-weight:bold;\">Adding MEX endpoints programmatically<\/font><\/h3>\n<p><font color=\"#000080\">like any other endpoint, you can also add metadata exchange endpoint programmatically before opening the host. WCF does not offer a dedicated binding type for the metadata exchange endpoint. you can use the following methods of <\/font><font color=\"#000080\"><strong>MetadataExchangeBindings<\/strong>&#160; class defined in <strong>System.ServiceModal.Description<\/strong><\/font><\/p>\n<p><font color=\"#0000ff\" size=\"2\">Uri tcpbaseAdr = new Uri ( \u201cnet.tcp:\/\/localhost:9000\/\u201d);      <br \/>ServiceHost host = new ServiceHost ( typeof (MyService), tcpbaseAdr );       <br \/>ServiceMetadataBehavior metaBehave ;       <br \/>metaBehave = host.Description.Behaviors.Find&lt;ServiceMetadataBehavior&gt;();       <br \/>if ( metaBehave == null )       <br \/>{       <br \/>&#160;&#160;&#160; metaBehave = new ServiceMetadataBehavior();       <br \/>&#160;&#160;&#160; host.Description.Behaviors.Add (metaBehave);       <br \/>}       <br \/>Binding binding = MetadataExchangeBindings.CreateMexTcpBinding ();       <br \/>host.AddServiceEndpoint (typeof (IMetadataExchange), binding, &quot;MEX&quot;);       <br \/>host.Open ();<\/font><\/p>\n<p><font color=\"#000080\">you can also add a MEX endpoint using the standard MEX endpoint.<\/font><\/p>\n<p><font color=\"#0000ff\" size=\"2\">ServiceHost host = new ServiceHost (typeof(MyService));      <br \/>host.Description.Behaviors.Add(new ServiceMetadataBehavior());       <br \/>EndpointAddress address = new EndpointAddress ( &quot;<\/font><a href=\"http:\/\/localhost:8000\/MEX&quot;);\"><font color=\"#0000ff\" size=\"2\">http:\/\/localhost:8000\/MEX&quot;);<\/font><\/a>     <br \/><font color=\"#0000ff\" size=\"2\">ServiceEndPoint endpoint = new ServiceMetadataEndPoint(address) ;      <br \/>host.AddServiceEndpoint (endpont);       <br \/>host.Open ();<\/font><\/p>\n<h3><font style=\"font-weight:bold;\">Client side Programming <\/font><\/h3>\n<p><font color=\"#000080\">To invoke operations on a service, a client first need to import the service contract to client\u2019s native (environ.) .<\/font><\/p>\n<h3><font style=\"font-weight:bold;\">Client side Calling Service using Code<\/font><\/h3>\n<p><font color=\"#000080\">Just define the interface definition in the client application in a file, say <strong>IMyService.cs<\/strong>.<\/font><\/p>\n<p> <font color=\"#0000ff\" size=\"2\" face=\"Courier New\">   <\/p>\n<p><strong>[ServiceContract]        <br \/>public interface IMyService         <br \/>{         <br \/>&#160;&#160; [OperationContract]         <br \/>&#160;&#160;&#160; double AddNumber(double dblX, double dblY );&#160;&#160;&#160; <br \/>&#160;&#160; [OperationContract]         <br \/>&#160;&#160;&#160; double MultiplyNumber(double dblX, double dblY );&#160;&#160;&#160; <br \/>}         <br \/><\/strong><\/p>\n<p> <\/font>  <\/p>\n<p><font color=\"#000080\">assuming that Service is hosted at address \u201c<strong>http:\/\/localhost:8001\/MyService<\/strong>\/\u201d <\/font><\/p>\n<p><font color=\"#000080\">To invoke operations on a service, if you do not want to use a configuration file. a client need to create everything by hand.<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Courier New\"><font color=\"#0000ff\" size=\"2\" face=\"Courier New\"><strong>private void CallServiceFunctionOnHTTP ()          <br \/>{           <br \/>&#160;&#160;&#160; string strAdr =<\/strong> <strong>\u201c<\/strong><\/font><font color=\"#0000ff\" size=\"2\" face=\"Courier New\"><strong>http:\/\/localhost:8001\/MyService\/\u201d;<\/strong><\/font>       <br \/><font color=\"#0000ff\" size=\"2\" face=\"Courier New\"><strong>&#160;&#160;&#160; Uri adrbase = new Uri(strAdr);          <br \/>&#160;&#160;&#160; BasicHttpBinding httpb = new BasicHttpBinding();           <br \/>&#160;&#160;&#160; ChannelFactory&lt;IMyService&gt; channelFactory = new ChannelFactory&lt;IMyService&gt;(httpb);           <br \/>&#160;&#160;&#160; <br \/>&#160;&#160;&#160; strEPAdr = &quot;<\/strong><\/font><font color=\"#0000ff\" size=\"2\" face=\"Courier New\"><strong>http:\/\/localhost:8001\/MyService<\/strong>&quot;<\/font><font color=\"#0000ff\" size=\"2\" face=\"Courier New\"><strong> ;          <br \/>&#160;&#160;&#160; EndpointAddress ep = new EndpointAddress(strEPAdr );           <br \/>&#160;&#160;&#160; IMyService myObj = m_ChannelFactory.CreateChannel(ep);           <br \/>&#160;&#160;&#160; double dblResult = 0;           <br \/>&#160;&#160;&#160; dblResult = chatObj.AddNumber(dblX, dblY);           <br \/>}<\/strong><\/font><\/font><\/p>\n<p><font color=\"#000080\">If the same Service also exposes another EndPoint (let say at &quot;<strong>net.tcp:\/\/localhost:9000\/MyService<\/strong>\u201d ) then you can call the service, through this end point as shown below.<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Courier New\"><font color=\"#0000ff\" size=\"2\" face=\"Courier New\"><strong>private void CallServiceFunctionOnTCP ()          <br \/>{           <br \/>&#160;&#160;&#160; string strAdr =<\/strong> <strong>\u201c<\/strong><\/font><strong><font color=\"#0000ff\" size=\"2\" face=\"Courier New\">net.tcp:\/\/localhost:9000\/MyService\/\u201d;<\/font>         <br \/><\/strong><strong><font color=\"#0000ff\" size=\"2\" face=\"Courier New\">&#160;&#160;&#160; Uri adrbase = new Uri(strAdr);          <br \/>&#160;&#160;&#160; NetTcpBinding tcpb = new NetTcpBinding();           <br \/>&#160;&#160;&#160; ChannelFactory&lt;IMyService&gt; channelFactory = new ChannelFactory&lt;IMyService&gt;(tcpb);           <br \/>&#160;&#160;&#160; <br \/>&#160;&#160;&#160; strEPAdr = &quot;<\/font><font color=\"#0000ff\" size=\"2\" face=\"Courier New\">net.tcp:\/\/localhost:9000\/MyService<\/font><\/strong><a href=\"http:\/\/localhost:8001\/MyService&quot;\"><font color=\"#0000ff\" size=\"2\" face=\"Courier New\">&quot;<\/font><\/a><font color=\"#0000ff\" size=\"2\" face=\"Courier New\"><strong> ;          <br \/>&#160;&#160;&#160; EndpointAddress ep = new EndpointAddress(strEPAdr );           <br \/>&#160;&#160;&#160; IMyService myObj = m_ChannelFactory.CreateChannel(ep);           <br \/>&#160;&#160;&#160; double dblResult = 0;           <br \/>&#160;&#160;&#160; dblResult = chatObj.AddNumber(dblX, dblY);           <br \/>}<\/strong><\/font><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is WCF In a nutshell, WCF is a SDK for developing and deploying services on Windows, although services can be build even without WCF.&#160; Developing services with WCF is easier. WCF is Microsoft\u2019s implementation of a set of industry standards defining service interactions, type conversions, marshaling, and management of various protocols. consequently, WCF provides&hellip; <a class=\"more-link\" href=\"https:\/\/praveenkatiyar.in\/blog\/index.php\/2013\/08\/20\/introduction-to-wcf\/\">Continue reading <span class=\"screen-reader-text\">Introduction to WCF<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,12],"tags":[17,33,34],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-codeproject","category-soa","tag-net","tag-wcf","tag-wcf-service","entry"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":0,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"wp:attachment":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}