PHP core technology and best practices PHP uses PHPRPC protocol to call JAVA class
- SOAP (Simple Object Access Protocol, Simple Object Access Protocol) with the continuous competition and design of manufacturers, and because the transfer of objects cannot achieve interoperability, SOAP gradually changes to the transfer of strings, and is finally designed as the XML-based WebService.
- PHPRPC protocol: it is a lightweight, secure, cross-Internet, cross-language, cross-platform, cross-environment, cross-domain protocol that supports transmission of complex objects and reference parameters, content output redirection, hierarchical error processing, and Sessions are service-oriented high-performance remote process calling protocols that are fast, mainly because of their data serialization and transmission.
- How to use PHP to call the JAVA class can be implemented through php-java-bridge, and WebService can also be used by middleware such as ICE, which is implemented through PHPRPC, download the corresponding software package from the PHPRPC website and copy the corresponding file to the lib directory of JAVA and the PHP Directory (see). The following describes the implementation process: output function: connect to the database to obtain all user functions: define the requested jsp page in JAVA:
Copy the corresponding package from the PHPRPC-JAVA to the lib Directory
Browser page request result (open the new tab to view the large image ):
-
You can also use PHP as the server. the code is as follows:
Server:
Include 'phprpc/phprpc_server.php ';
Class Hello {
Static function HelloWorld (){
Return 'Hello World! ';
}
}
$ Server = new PHPRPC_Server ();
$ Server-> add ('helloworld', 'Hello ');
$ Server-> start ();