Distributed application how to
I searched a lot but maybe i am missing something...
I am wondering about the best practices when you have different platforms (dekstop, web,mobile,terminals) how to avoid writing bussiness logic again and again. I know Web Servic开发者_JAVA百科es, EJB etc are for this purpose,REST. But i dont know whether these technologies are compatible.. If i want to use java for desktop and php for web application then how tek heck i can achieve this??With a little searching i found that RESTful might be a solution... Any other ideas/ architectures?Yes, the technologies that you mention (Web Services, EJBs ,REST, ..) are meant to be for deploying service infrastructures. The key point about compatibility is that interfaces must be standard. In that sense, for instance EJBs are basically a J2EE technology that is only standard inside the JCP (Java Community Process), fair enough if you only care about compatibility in the J2EE world. You would not be able to make calls from a .Net client to a EJB, just to give an example.
On the other side, Web Services (as in SOAP, WSDL and XML) is a W3C standard, that means that protocols, messages, formats, etc. are independent from the technology. So, for instance you could publish a service with Java using Axis and develop a client in .Net, python, C or any other language to send messages. That is good, but in the case of Web Services the layer of standards just went crazy over the last years. To be honest, is really easy to get lost in the universe of standards that came up around Service Oriented Architectures and Web Services.
REST services are also a kind of standard, they basically rely on URL composition and HTTP to build up a communication mechanism between servers and clients. Much more simple than SOAP/WSDL. Most languages, today, offer libraries to consume and publish this kind of services using JSON as data format. In REST, interfaces are lighter than in SOAP/WSDL, you don't have an XML file that defines your service but normally rather than being an issue is an advantage.
At the end of the day, if you care about compatibility then code to standards and don't lock yourself into any proprietary formats. With REST and Web Services you should be safe. From these two options REST services would be my choice.
PS: other distributed architectures, not so much used today as the ones that you mentioned, are: RPC/XML, COM and CORBA.
精彩评论