WCF to some extent violates the principle of SOA
2011-07-14 22:41
423 查看
as we know, WCF is designed by Microsoft for the SOA in the windows platform, but in my opinion , that to some extent violates the pricinple io SOA and also to some extent jeopardizes it.
As the some pinciples of SOA are concerned, a service should be state-less, it is expected to return the same result no matter which client calls it if the clients give the same input.
But WCF got three instant mode available:
Per-Call
Per-Session
Singleton
Per-Call instance mode with a new instant by every call satisfies what the SOA requires, WCF create a absolute new instance for every call. so they don't affect each other anyway.
ex:
the above is set to Per-Call mode, so let's check the client code and its correspoding result.
Per-Session being a state-ware instant mode is not what the SOA requires, becasue all calls in a client share the only one instance. so maybe the fist call’s operation can affect the next call’s result. give a little code as exapmle(just the same code as the above but switch the instance mode to Per-Serssion):
the above is set to Per-serssion mode, so let's check the result again.
I dont want to talk about the Singlton mode anyway, it is extremely much worse than the Per-session mode if the SOA is concerned. becasue Singleton mode makes all of the client share one instance. so thinking how it gonna look like
BTW, Per-call mode works well with the transaction, it is very complex when the mode comes to the Per-Session or Singleton.
Anyway, everything is possible if it exists. WCF is designed not only for the SOA, which makes it possible for us to make the classic ASP.NET application or client/server application.
As the some pinciples of SOA are concerned, a service should be state-less, it is expected to return the same result no matter which client calls it if the clients give the same input.
But WCF got three instant mode available:
Per-Call
Per-Session
Singleton
Per-Call instance mode with a new instant by every call satisfies what the SOA requires, WCF create a absolute new instance for every call. so they don't affect each other anyway.
ex:
public class Calculator:ICalculator,IDisposable { double result; public double Add(double x, double y) { this.result += x + y; return x + y; } public double GetResult() { return this.result; } }
the above is set to Per-Call mode, so let's check the client code and its correspoding result.
MyClientCalculator proxy=MyClientCalculator (); proxy.Add(1,1); proxy.GetResult();//here print:2 proxy.Add(1,1);//again with the some input(1,1) as last one proxy.GetResult();//here print:2,Note we get the same result with the same input.
Per-Session being a state-ware instant mode is not what the SOA requires, becasue all calls in a client share the only one instance. so maybe the fist call’s operation can affect the next call’s result. give a little code as exapmle(just the same code as the above but switch the instance mode to Per-Serssion):
public class Calculator:ICalculator,IDisposable { double result; public double Add(double x, double y) { this.result += x + y; return x + y; } public double GetResult() { return this.result; } }
the above is set to Per-serssion mode, so let's check the result again.
MyClientCalculator proxy=MyClientCalculator (); proxy.Add(1,1); proxy.GetResult();//here print:2 proxy.Add(1,1);//again with the some input(1,1) as last one proxy.GetResult();//here print:4,Note we get the different result but with the same input.
I dont want to talk about the Singlton mode anyway, it is extremely much worse than the Per-session mode if the SOA is concerned. becasue Singleton mode makes all of the client share one instance. so thinking how it gonna look like
BTW, Per-call mode works well with the transaction, it is very complex when the mode comes to the Per-Session or Singleton.
Anyway, everything is possible if it exists. WCF is designed not only for the SOA, which makes it possible for us to make the classic ASP.NET application or client/server application.
相关文章推荐
- 每日英语:These Gadgets Aim To Put Some Teeth Into The Internet Of Things
- [Java][DB][Cassandra] some useful link to understand the concepts of SSTable
- These kinds of timepieces are usually far better cloned as compared to some other timepieces because of the sought after and also reputation
- How to arrange 10 digits so that the product of the some of them is equal to a number represented by the remaining digits
- How to arrange 10 digits so that the product of the some of them is equal to a number represented by the remaining digits
- What are some of the differences between using recursion to solve a problem versus using iteration?
- [PHP] To display some attribute of the node in the XML document.
- how to get the space size of some tables in one database?
- C# Need to understand some of the technical (C# 需要懂的一些技术)
- Beginning the journey of WCF, and look forward to future.
- Some notes of The Peter Principle
- The Transition from Qt 4.x to Qt 5, the compatibility of QT, the solution to some error of header in
- Question 33: How can a C++ developer use the placement new syntax to make new allocate an object of class SomeClass at a particu
- how to get the space size of some tables in one database?
- How to trace the Geolocation of network traffic
- The type of feed to provide for blog posts
- INS-35354] The system on which you are attempting to install Oracle RAC is not part of a valid clust
- Android - How to direct the audio data from MediaRecorder as the input of ffmpeg command via Pipe?
- 错误 You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work
- The object of type 'RectTransform' has been destroyed but you are still trying to access it