WCF, very good, but also troublesome, many times do not want to use WCF reason is: With this really troublesome ...
Troublesome places, such as:
A heap of service configurations, scattered under one folder, error prone to update the system
The client must know the location of the service provider in addition to the WCF contract
So there is a way to simplify these, the main idea is:
Join internal communication Service, referred to as ICS. Used to insert a custom middle tier
Write a service Locator service that is used to extract WCF service provider information for unified storage, such as URL, endpoint type, WCF service provider location-Independent
When completed, WCF clients, including services that call other WCF services within the WCF service ... The calling code changes to the following ways:
Does not support the way transactions are invoked
iuser usersrv = icsfactory.create<iuser> ();
var result = Usersrv.getusername ("1", "2",
"3");
Icsfactory.close (USERSRV);
Calling method that supports transactions
string result = String. Empty;
using (TransactionScope ts = new TransactionScope ())
{
Iuser usersrv = icsfactory.create<iuser> ();
Iadmin adminsrv = icsfactory.create<iadmin> ();
result = Usersrv.getusername ("1", "2",
"3");
result = adminsrv.checkpermission (100). ToString ();
Ts.complete ();
Icsfactory.close (USERSRV);
Icsfactory.close (ADMINSRV);
}
Configuration information for WCF clients where are we going? A: In AppSetting, there is a key that represents the path to the service configuration information file, such as: \\fs\root\a2d.service.config, the configuration file is as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<A2D>
<ServiceLocator>
<service Contractnamespace= "Desbinterface"
contract= "Iuser" >
<url endpointtype=
"TCP" >net.tcp:// 192.168.1.100:9999/usersrv<
;/url>
</Service>
<service contractnamespace= " Desbinterface "
contract=" Iadmin ">
<url
endpointtype=" TCP ">net.tcp://192.168.1.100:9998 /adminsrv&l
t;/url>
</Service>
</ServiceLocator>
</A2D>
If the client calling the WCF service has only one program, it won't be much use, but if you have a lot of client programs, that's useful, as in the following scenario:
4 servers are called as clients for WCF services