Architecture for Services (WCF and Delphi)
I'm working on a project that will have two user interfaces. Web (asp.net MVC) and Desktop (Delphi 2010). It was requested by the customer, so we need to开发者_如何学Python use Delphi.
We're thinking of architecture oriented by services, and so is WCF. To access WCF Services in Asp.Net MVC it is fine but what Need I do in Delphi? My principal doubt is, how to access a service in WCF using Delphi. Is there any way to make it easy?
Can my methods in service return IEnumerable or T[]? Are there recommendations for this !?
Thanks!
The web services support in WCF provides many features which are not suported by Delphi - MTOM, WS-Addressing, WS-Reliable Messaging and WS-Security just to name a few. If you are designing both parts of the system (web service server and client(s)), you are in the happy situation that you can choose which features to use (as long as they are not dictated by other parties).
WCF fortunately does not 'dictate' to use SOAP. The Interoperability section in this Wikipedia article mentions for example WCF with standard XML (or RSS, or JSON). There is also a WCF binding for REST.
Planning a service oriented architecture is a tough task, so I highly recommend to read through the usual literature for this topic, and find a way to keep it as simple as possible and easy to test and evolve.
Maybe you can take a look at RemObjects SDK: it is a WCF-like solution, and you can use it for .Net, Delphi, Objective-C, PHP, C++, etc.
So you can build a server with RemObjects for .Net, for example TCP + Binary message for best performance (SOAP/XML is much slower!), and a Delphi 2010 client (even FreePascal is supported). Both sides (Delphi and .Net) are compatible with each other, even for the binary message!
My experience with RemObjects is very good: very easy to use and to build services (easier than WCF?), good support and quality etc.
One of the latest SOA framework for Delphi, is our Open Source mORMot framework.
You can use interface
to define your Service contract, and access to them locally or remotely using named pipes, GDI messages, or TCP/HTTP. Your contract is defined as such on both client and server side, just like in WCF.
type
ICalculator = interface(IInvokable)
['{9A60C8ED-CEB2-4E09-87D4-4A16F496E5FE}']
function Add(n1,n2: integer): integer;
end;
It handles per-call, per-session, per-user or per-group instance live. See this sample code.
It is secure (with secure authentication at URI level), light and fast.
It uses JSON as communication (lighter than XML), and a RESTful access. It is ready to be consumed by AJAX or WCF clients (the latest after custom marshaling of the interfaces). It was optimized for speed and scalability (with advanced features like balanced custom hosting and per-interface/per-method access security).
The mORMot framework documentation has more than 800 pages, and some dedicated high-level explanation of Service Oriented Architecture design pattern in Delphi. It is integrated with a Client-Server ORM, so you have at hand all needed low-level tools to make a proper Domain-Driven application in Delphi, and other technologies.
精彩评论